@@ -584,4 +584,46 @@ func TestEnterprisePostUser(t *testing.T) {
584
584
})
585
585
require .ErrorContains (t , err , "No organization specified" )
586
586
})
587
+
588
+ t .Run ("MultipleOrganizations" , func (t * testing.T ) {
589
+ t .Parallel ()
590
+ dv := coderdtest .DeploymentValues (t )
591
+ dv .Experiments = []string {string (codersdk .ExperimentMultiOrganization )}
592
+
593
+ client , _ := coderdenttest .New (t , & coderdenttest.Options {
594
+ Options : & coderdtest.Options {
595
+ DeploymentValues : dv ,
596
+ },
597
+ LicenseOptions : & coderdenttest.LicenseOptions {
598
+ Features : license.Features {
599
+ codersdk .FeatureMultipleOrganizations : 1 ,
600
+ },
601
+ },
602
+ })
603
+
604
+ // Add an extra org to assign member into
605
+ second := coderdenttest .CreateOrganization (t , client , coderdenttest.CreateOrganizationOptions {})
606
+ third := coderdenttest .CreateOrganization (t , client , coderdenttest.CreateOrganizationOptions {})
607
+
608
+ ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
609
+ defer cancel ()
610
+
611
+ // nolint:gocritic // intentional using the owner.
612
+ // Manually making a user with the request instead of the coderdtest util
613
+ user , err := client .CreateUser (ctx , codersdk.CreateUserRequest {
614
+ Email : "another@user.org" ,
615
+ Username : "someone-else" ,
616
+ Password : "SomeSecurePassword!" ,
617
+ OrganizationIDs : []uuid.UUID {
618
+ second .ID ,
619
+ third .ID ,
620
+ },
621
+ })
622
+ require .NoError (t , err )
623
+
624
+ memberedOrgs , err := client .OrganizationsByUser (ctx , user .ID .String ())
625
+ require .NoError (t , err )
626
+ require .Len (t , memberedOrgs , 2 )
627
+ require .ElementsMatch (t , []uuid.UUID {second .ID , third .ID }, []uuid.UUID {memberedOrgs [0 ].ID , memberedOrgs [1 ].ID })
628
+ })
587
629
}
0 commit comments