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

Function TestGroupEdit

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

Source from the content-addressed store, hash-verified

18)
19
20func TestGroupEdit(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 _, user3 := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID)
36
37 group := coderdtest.CreateGroup(t, client, admin.OrganizationID, "alpha", user3)
38
39 expectedName := "beta"
40
41 inv, conf := newCLI(
42 t,
43 "groups", "edit", group.Name,
44 "--name", expectedName,
45 "--avatar-url", "https://example.com",
46 "-a", user1.ID.String(),
47 "-a", user2.Email,
48 "-r", user3.ID.String(),
49 )
50
51 pty := ptytest.New(t)
52
53 inv.Stdout = pty.Output()
54 clitest.SetupConfig(t, anotherClient, conf)
55
56 err := inv.Run()
57 require.NoError(t, err)
58
59 pty.ExpectMatch(fmt.Sprintf("Successfully patched group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, expectedName)))
60 })
61
62 t.Run("InvalidUserInput", func(t *testing.T) {
63 t.Parallel()
64
65 client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
66 Features: license.Features{
67 codersdk.FeatureTemplateRBAC: 1,
68 },
69 }})
70
71 // Create a group with no members.
72 group := coderdtest.CreateGroup(t, client, admin.OrganizationID, "alpha")
73
74 inv, conf := newCLI(
75 t,
76 "groups", "edit", group.Name,
77 "-a", "foo",

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected