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

Function TestOrganizationByUserAndName

coderd/organizations_test.go:14–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestOrganizationByUserAndName(t *testing.T) {
15 t.Parallel()
16 t.Run("NoExist", func(t *testing.T) {
17 t.Parallel()
18 client := coderdtest.New(t, nil)
19 coderdtest.CreateFirstUser(t, client)
20 ctx := testutil.Context(t, testutil.WaitLong)
21
22 _, err := client.OrganizationByUserAndName(ctx, codersdk.Me, "nothing")
23 var apiErr *codersdk.Error
24 require.ErrorAs(t, err, &apiErr)
25 require.Equal(t, http.StatusNotFound, apiErr.StatusCode())
26 })
27
28 t.Run("Valid", func(t *testing.T) {
29 t.Parallel()
30 client := coderdtest.New(t, nil)
31 user := coderdtest.CreateFirstUser(t, client)
32 ctx := testutil.Context(t, testutil.WaitLong)
33
34 org, err := client.Organization(ctx, user.OrganizationID)
35 require.NoError(t, err)
36 _, err = client.OrganizationByUserAndName(ctx, codersdk.Me, org.Name)
37 require.NoError(t, err)
38 })
39}

Callers

nothing calls this directly

Calls 8

StatusCodeMethod · 0.95
NewFunction · 0.92
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45
OrganizationMethod · 0.45

Tested by

no test coverage detected