@@ -258,7 +258,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
258
258
t .Run ("NotFound" ,func (t * testing.T ) {
259
259
t .Parallel ()
260
260
client := coderdtest .New (t ,nil )
261
- _ ,err := client .WorkspaceByOwnerAndName (context .Background (),codersdk .Me ,"something" , codersdk.WorkspaceByOwnerAndNameParams {})
261
+ _ ,err := client .WorkspaceByOwnerAndName (context .Background (),codersdk .Me ,"something" , codersdk.WorkspaceOptions {})
262
262
var apiErr * codersdk.Error
263
263
require .ErrorAs (t ,err ,& apiErr )
264
264
require .Equal (t ,http .StatusUnauthorized ,apiErr .StatusCode ())
@@ -271,7 +271,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
271
271
coderdtest .AwaitTemplateVersionJob (t ,client ,version .ID )
272
272
template := coderdtest .CreateTemplate (t ,client ,user .OrganizationID ,version .ID )
273
273
workspace := coderdtest .CreateWorkspace (t ,client ,user .OrganizationID ,template .ID )
274
- _ ,err := client .WorkspaceByOwnerAndName (context .Background (),codersdk .Me ,workspace .Name , codersdk.WorkspaceByOwnerAndNameParams {})
274
+ _ ,err := client .WorkspaceByOwnerAndName (context .Background (),codersdk .Me ,workspace .Name , codersdk.WorkspaceOptions {})
275
275
require .NoError (t ,err )
276
276
})
277
277
t .Run ("Deleted" ,func (t * testing.T ) {
@@ -294,12 +294,43 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
294
294
295
295
// Then:
296
296
// When we call without includes_deleted, we don't expect to get the workspace back
297
- _ ,err = client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceByOwnerAndNameParams {})
297
+ _ ,err = client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceOptions {})
298
298
require .ErrorContains (t ,err ,"403" )
299
299
300
300
// Then:
301
301
// When we call with includes_deleted, we should get the workspace back
302
- workspaceNew ,err := client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceByOwnerAndNameParams {IncludeDeleted :true })
302
+ workspaceNew ,err := client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceOptions {IncludeDeleted :true })
303
+ require .NoError (t ,err )
304
+ require .Equal (t ,workspace .ID ,workspaceNew .ID )
305
+
306
+ // Given:
307
+ // We recreate the workspace with the same name
308
+ workspace ,err = client .CreateWorkspace (context .Background (),user .OrganizationID , codersdk.CreateWorkspaceRequest {
309
+ TemplateID :workspace .TemplateID ,
310
+ Name :workspace .Name ,
311
+ AutostartSchedule :workspace .AutostartSchedule ,
312
+ TTLMillis :workspace .TTLMillis ,
313
+ })
314
+ require .NoError (t ,err )
315
+ coderdtest .AwaitWorkspaceBuildJob (t ,client ,workspace .LatestBuild .ID )
316
+
317
+ // Then:
318
+ // We can fetch the most recent workspace
319
+ workspaceNew ,err = client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceOptions {})
320
+ require .NoError (t ,err )
321
+ require .Equal (t ,workspace .ID ,workspaceNew .ID )
322
+
323
+ // Given:
324
+ // We delete the workspace again
325
+ build ,err = client .CreateWorkspaceBuild (context .Background (),workspace .ID , codersdk.CreateWorkspaceBuildRequest {
326
+ Transition :codersdk .WorkspaceTransitionDelete ,
327
+ })
328
+ require .NoError (t ,err ,"delete the workspace" )
329
+ coderdtest .AwaitWorkspaceBuildJob (t ,client ,build .ID )
330
+
331
+ // Then:
332
+ // When we fetch the deleted workspace, we get the most recently deleted one
333
+ workspaceNew ,err = client .WorkspaceByOwnerAndName (context .Background (),workspace .OwnerName ,workspace .Name , codersdk.WorkspaceOptions {IncludeDeleted :true })
303
334
require .NoError (t ,err )
304
335
require .Equal (t ,workspace .ID ,workspaceNew .ID )
305
336
})