@@ -42,4 +42,35 @@ func TestCurrentOrganization(t *testing.T) {
42
42
require .NoError (t , <- errC )
43
43
pty .ExpectMatch (first .OrganizationID .String ())
44
44
})
45
+
46
+ t .Run ("UsingFlag" , func (t * testing.T ) {
47
+ t .Parallel ()
48
+ ownerClient := coderdtest .New (t , nil )
49
+ first := coderdtest .CreateFirstUser (t , ownerClient )
50
+ // Owner is required to make orgs
51
+ client , _ := coderdtest .CreateAnotherUser (t , ownerClient , first .OrganizationID , rbac .RoleOwner ())
52
+
53
+ ctx := testutil .Context (t , testutil .WaitMedium )
54
+ orgs := map [string ]codersdk.Organization {
55
+ "foo" : {},
56
+ "bar" : {},
57
+ }
58
+ for orgName := range orgs {
59
+ org , err := client .CreateOrganization (ctx , codersdk.CreateOrganizationRequest {
60
+ Name : orgName ,
61
+ })
62
+ require .NoError (t , err )
63
+ orgs [orgName ] = org
64
+ }
65
+
66
+ inv , root := clitest .New (t , "organizations" , "current" , "--only-id" , "-z=bar" )
67
+ clitest .SetupConfig (t , client , root )
68
+ pty := ptytest .New (t ).Attach (inv )
69
+ errC := make (chan error )
70
+ go func () {
71
+ errC <- inv .Run ()
72
+ }()
73
+ require .NoError (t , <- errC )
74
+ pty .ExpectMatch (orgs ["bar" ].ID .String ())
75
+ })
45
76
}
0 commit comments