MCPcopy Index your code
hub / github.com/devopsctl/gitlabctl / TestDeleteAllMembers

Function TestDeleteAllMembers

cmd/delete_all_members_test.go:30–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestDeleteAllMembers(t *testing.T) {
31 tg := []struct {
32 name string
33 args []string
34 flagsMap map[string]string
35 expect testResult
36 }{
37 {
38 name: "delete all from a project",
39 flagsMap: map[string]string{
40 "from-project": "TestDeleteAllMembersProject",
41 },
42 expect: pass,
43 },
44 }
45 t.Run(tg[0].name, func(t *testing.T) {
46 // SETUP:
47 // create the test project
48 gid, _ := getNamespaceID("Group1")
49 if _, err := newProject(&gitlab.CreateProjectOptions{
50 Path: gitlab.String(tg[0].flagsMap["from-project"]),
51 Name: gitlab.String(tg[0].flagsMap["from-project"]),
52 NamespaceID: gitlab.Int(gid),
53 }); err != nil {
54 tInfo(err)
55 }
56
57 tg[0].flagsMap["from-project"] = "Group1/" + tg[0].flagsMap["from-project"]
58 // add project members
59 if _, err := newProjectMember(tg[0].flagsMap["from-project"],
60 "john.smith",
61 &gitlab.AddProjectMemberOptions{
62 AccessLevel: gitlab.AccessLevel(40),
63 }); err != nil {
64 tInfo(err)
65 }
66
67 if _, err := newProjectMember(tg[0].flagsMap["from-project"],
68 "john.doe",
69 &gitlab.AddProjectMemberOptions{
70 AccessLevel: gitlab.AccessLevel(40),
71 }); err != nil {
72 tInfo(err)
73 }
74
75 execT := execTestCmdFlags{
76 t: t,
77 cmd: deleteAllMembersCmd,
78 flagsMap: tg[0].flagsMap,
79 }
80 stdout, execResult := execT.executeCommand()
81 assertEqualResult(t, tg[0].expect, execResult, stdout)
82
83 // delete test project
84 if err := deleteProject(tg[0].flagsMap["from-project"]); err != nil {
85 tInfo("Removal of test data failure for delete all-members test")
86 }
87

Callers

nothing calls this directly

Calls 8

executeCommandMethod · 0.95
getNamespaceIDFunction · 0.85
newProjectFunction · 0.85
tInfoFunction · 0.85
newProjectMemberFunction · 0.85
assertEqualResultFunction · 0.85
deleteProjectFunction · 0.85
assertOutContainsFunction · 0.85

Tested by

no test coverage detected