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

Function TestShowOrganizationRoles

cli/organizationroles_test.go:18–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestShowOrganizationRoles(t *testing.T) {
19 t.Parallel()
20
21 t.Run("OK", func(t *testing.T) {
22 t.Parallel()
23
24 ownerClient, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{})
25 owner := coderdtest.CreateFirstUser(t, ownerClient)
26 client, _ := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID, rbac.RoleUserAdmin())
27
28 const expectedRole = "test-role"
29 dbgen.CustomRole(t, db, database.CustomRole{
30 Name: expectedRole,
31 DisplayName: "Expected",
32 SitePermissions: nil,
33 OrgPermissions: nil,
34 UserPermissions: nil,
35 OrganizationID: uuid.NullUUID{
36 UUID: owner.OrganizationID,
37 Valid: true,
38 },
39 })
40
41 ctx := testutil.Context(t, testutil.WaitMedium)
42 inv, root := clitest.New(t, "organization", "roles", "show")
43 clitest.SetupConfig(t, client, root)
44
45 buf := new(bytes.Buffer)
46 inv.Stdout = buf
47 err := inv.WithContext(ctx).Run()
48 require.NoError(t, err)
49 require.Contains(t, buf.String(), expectedRole)
50 })
51}

Callers

nothing calls this directly

Calls 12

NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleUserAdminFunction · 0.92
CustomRoleFunction · 0.92
ContextFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
WithContextMethod · 0.80
RunMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected