@@ -260,8 +260,9 @@ func TestCreateUserWorkspace(t *testing.T) {
260
260
},
261
261
LicenseOptions :& coderdenttest.LicenseOptions {
262
262
Features : license.Features {
263
- codersdk .FeatureCustomRoles :1 ,
264
- codersdk .FeatureTemplateRBAC :1 ,
263
+ codersdk .FeatureCustomRoles :1 ,
264
+ codersdk .FeatureTemplateRBAC :1 ,
265
+ codersdk .FeatureMultipleOrganizations :1 ,
265
266
},
266
267
},
267
268
})
@@ -277,9 +278,13 @@ func TestCreateUserWorkspace(t *testing.T) {
277
278
}),
278
279
})
279
280
require .NoError (t ,err )
281
+ secondOrg := coderdenttest .CreateOrganization (t ,owner , coderdenttest.CreateOrganizationOptions {})
280
282
281
283
// use admin for setting up test
282
- admin ,adminID := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .RoleTemplateAdmin ())
284
+ admin ,_ := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .RoleTemplateAdmin ())
285
+
286
+ // user to make the workspace for, **note** the user is not a member of the first org.
287
+ _ ,forUser := coderdtest .CreateAnotherUser (t ,owner ,secondOrg .ID )
283
288
284
289
// try the test action with this user & custom role
285
290
creator ,_ := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .RoleMember (), rbac.RoleIdentifier {
@@ -293,14 +298,14 @@ func TestCreateUserWorkspace(t *testing.T) {
293
298
294
299
ctx = testutil .Context (t ,testutil .WaitLong * 1000 )// Reset the context to avoid timeouts.
295
300
296
- wrk ,err := creator .CreateUserWorkspace (ctx ,adminID .ID .String (), codersdk.CreateWorkspaceRequest {
301
+ wrk ,err := creator .CreateUserWorkspace (ctx ,forUser .ID .String (), codersdk.CreateWorkspaceRequest {
297
302
TemplateID :template .ID ,
298
303
Name :"workspace" ,
299
304
})
300
305
require .NoError (t ,err )
301
306
coderdtest .AwaitWorkspaceBuildJobCompleted (t ,admin ,wrk .LatestBuild .ID )
302
307
303
- _ ,err = creator .WorkspaceByOwnerAndName (ctx ,adminID .Username ,wrk .Name , codersdk.WorkspaceOptions {
308
+ _ ,err = creator .WorkspaceByOwnerAndName (ctx ,forUser .Username ,wrk .Name , codersdk.WorkspaceOptions {
304
309
IncludeDeleted :false ,
305
310
})
306
311
require .NoError (t ,err )