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

Function TestGroupList

enterprise/cli/grouplist_test.go:20–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestGroupList(t *testing.T) {
21 t.Parallel()
22
23 t.Run("OK", func(t *testing.T) {
24 t.Parallel()
25
26 client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
27 Features: license.Features{
28 codersdk.FeatureTemplateRBAC: 1,
29 },
30 }})
31 anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID, rbac.RoleUserAdmin())
32
33 _, user1 := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
34 _, user2 := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
35
36 // We intentionally create the first group as beta so that we
37 // can assert that things are being sorted by name intentionally
38 // and not by chance (or some other parameter like created_at).
39 group1 := coderdtest.CreateGroup(t, client, admin.OrganizationID, "beta", user1)
40 group2 := coderdtest.CreateGroup(t, client, admin.OrganizationID, "alpha", user2)
41
42 inv, conf := newCLI(t, "groups", "list")
43
44 pty := ptytest.New(t)
45
46 inv.Stdout = pty.Output()
47 clitest.SetupConfig(t, anotherClient, conf)
48
49 err := inv.Run()
50 require.NoError(t, err)
51
52 matches := []string{
53 "NAME", "ORGANIZATION ID", "MEMBERS", " AVATAR URL",
54 group2.Name, group2.OrganizationID.String(), user2.Email, group2.AvatarURL,
55 group1.Name, group1.OrganizationID.String(), user1.Email, group1.AvatarURL,
56 }
57
58 for _, match := range matches {
59 pty.ExpectMatch(match)
60 }
61 })
62
63 t.Run("Everyone", func(t *testing.T) {
64 t.Parallel()
65
66 client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
67 Features: license.Features{
68 codersdk.FeatureTemplateRBAC: 1,
69 },
70 }})
71 anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID, rbac.RoleUserAdmin())
72
73 inv, conf := newCLI(t, "groups", "list")
74
75 pty := ptytest.New(t)
76
77 inv.Stdout = pty.Output()

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
CreateAnotherUserFunction · 0.92
RoleUserAdminFunction · 0.92
CreateGroupFunction · 0.92
NewFunction · 0.92
SetupConfigFunction · 0.92
newCLIFunction · 0.85
RunMethod · 0.65
OutputMethod · 0.65
StringMethod · 0.45
ExpectMatchMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected