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

Function TestMultiOrgFetch

enterprise/coderd/organizations_test.go:19–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestMultiOrgFetch(t *testing.T) {
20 t.Parallel()
21 client, _ := coderdenttest.New(t, &coderdenttest.Options{
22 LicenseOptions: &coderdenttest.LicenseOptions{
23 Features: license.Features{
24 codersdk.FeatureMultipleOrganizations: 1,
25 },
26 },
27 })
28
29 ctx := testutil.Context(t, testutil.WaitLong)
30
31 makeOrgs := []string{"foo", "bar", "baz"}
32 for _, name := range makeOrgs {
33 _, err := client.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{
34 Name: name,
35 DisplayName: name,
36 })
37 require.NoError(t, err)
38 }
39
40 //nolint:gocritic // using the owner intentionally since only they can make orgs
41 myOrgs, err := client.OrganizationsByUser(ctx, codersdk.Me)
42 require.NoError(t, err)
43 require.NotNil(t, myOrgs)
44 require.Len(t, myOrgs, len(makeOrgs)+1)
45
46 orgs, err := client.Organizations(ctx)
47 require.NoError(t, err)
48 require.NotNil(t, orgs)
49 require.ElementsMatch(t, myOrgs, orgs)
50}
51
52func TestOrganizationsByUser(t *testing.T) {
53 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
ContextFunction · 0.92
CreateOrganizationMethod · 0.80
OrganizationsByUserMethod · 0.80
OrganizationsMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected