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

Function TestGroupDelete

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

Source from the content-addressed store, hash-verified

18)
19
20func TestGroupDelete(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 group := coderdtest.CreateGroup(t, client, admin.OrganizationID, "alpha")
34
35 inv, conf := newCLI(t,
36 "groups", "delete", group.Name,
37 )
38
39 pty := ptytest.New(t)
40
41 inv.Stdout = pty.Output()
42 clitest.SetupConfig(t, anotherClient, conf)
43
44 err := inv.Run()
45 require.NoError(t, err)
46
47 pty.ExpectMatch(fmt.Sprintf("Successfully deleted group %s", pretty.Sprint(cliui.DefaultStyles.Keyword, group.Name)))
48 })
49
50 t.Run("NoArg", func(t *testing.T) {
51 t.Parallel()
52
53 client, admin := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{
54 Features: license.Features{
55 codersdk.FeatureTemplateRBAC: 1,
56 },
57 }})
58 anotherClient, _ := coderdtest.CreateAnotherUser(t, client, admin.OrganizationID, rbac.RoleUserAdmin())
59
60 inv, conf := newCLI(
61 t,
62 "groups", "delete",
63 )
64
65 clitest.SetupConfig(t, anotherClient, conf)
66
67 err := inv.Run()
68 require.Error(t, err)
69 })
70}

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
ExpectMatchMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected