MCPcopy Index your code
hub / github.com/coder/coder / TestShowOrganizations

Function TestShowOrganizations

enterprise/cli/organization_test.go:109–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestShowOrganizations(t *testing.T) {
110 t.Parallel()
111
112 t.Run("OnlyID", func(t *testing.T) {
113 t.Parallel()
114
115 ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{
116 Options: &coderdtest.Options{
117 IncludeProvisionerDaemon: true,
118 },
119 LicenseOptions: &coderdenttest.LicenseOptions{
120 Features: license.Features{
121 codersdk.FeatureMultipleOrganizations: 1,
122 codersdk.FeatureExternalProvisionerDaemons: 1,
123 },
124 },
125 })
126
127 // Owner is required to make orgs
128 client, _ := coderdtest.CreateAnotherUser(t, ownerClient, first.OrganizationID, rbac.RoleOwner())
129
130 ctx := testutil.Context(t, testutil.WaitMedium)
131 orgs := []string{"foo", "bar"}
132 for _, orgName := range orgs {
133 _, err := client.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{
134 Name: orgName,
135 })
136 require.NoError(t, err)
137 }
138
139 inv, root := clitest.New(t, "organizations", "show", "--only-id", "--org="+first.OrganizationID.String())
140 clitest.SetupConfig(t, client, root)
141 pty := ptytest.New(t).Attach(inv)
142 errC := make(chan error)
143 go func() {
144 errC <- inv.Run()
145 }()
146 require.NoError(t, <-errC)
147 pty.ExpectMatch(first.OrganizationID.String())
148 })
149
150 t.Run("UsingFlag", func(t *testing.T) {
151 t.Parallel()
152 ownerClient, first := coderdenttest.New(t, &coderdenttest.Options{
153 Options: &coderdtest.Options{
154 IncludeProvisionerDaemon: true,
155 },
156 LicenseOptions: &coderdenttest.LicenseOptions{
157 Features: license.Features{
158 codersdk.FeatureMultipleOrganizations: 1,
159 codersdk.FeatureExternalProvisionerDaemons: 1,
160 },
161 },
162 })
163
164 // Owner is required to make orgs
165 client, _ := coderdtest.CreateAnotherUser(t, ownerClient, first.OrganizationID, rbac.RoleOwner())
166

Callers

nothing calls this directly

Calls 12

NewFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleOwnerFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92
CreateOrganizationMethod · 0.80
RunMethod · 0.65
AttachMethod · 0.65
StringMethod · 0.45
ExpectMatchMethod · 0.45

Tested by

no test coverage detected