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

Function TestDeleteMember

cmd/delete_member_test.go:31–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestDeleteMember(t *testing.T) {
32 tg := []struct {
33 name string
34 args []string
35 flagsMap map[string]string
36 expect testResult
37 }{
38 {
39 name: "delete from a group",
40 args: []string{"kevin.mclean"},
41 flagsMap: map[string]string{
42 "from-group": "Group1",
43 },
44 expect: pass,
45 },
46 {
47 name: "delete from a project",
48 args: []string{"kylie.morrison"},
49 flagsMap: map[string]string{
50 "from-project": "Group1/Project1",
51 },
52 expect: pass,
53 },
54 }
55
56 t.Run(tg[0].name, func(t *testing.T) {
57 // SETUP:
58 // create the test member to be removed
59 if tg[0].expect == pass {
60 if _, err := newGroupMember(tg[0].flagsMap["from-group"],
61 tg[0].args[0],
62 &gitlab.AddGroupMemberOptions{
63 AccessLevel: gitlab.AccessLevel(40),
64 }); err != nil {
65 tInfo(err)
66 }
67 }
68
69 execT := execTestCmdFlags{
70 t: t,
71 cmd: deleteMemberCmd,
72 args: tg[0].args,
73 flagsMap: tg[0].flagsMap,
74 }
75 stdout, execResult := execT.executeCommand()
76 fmt.Println(stdout)
77 require.Equal(t, tg[0].expect, execResult, stdout)
78 })
79
80 t.Run(tg[1].name, func(t *testing.T) {
81 // SETUP:
82 // create the test member to be removed
83 if tg[0].expect == pass {
84 if _, err := newProjectMember(tg[1].flagsMap["from-project"],
85 tg[1].args[0],
86 &gitlab.AddProjectMemberOptions{
87 AccessLevel: gitlab.AccessLevel(40),
88 }); err != nil {

Callers

nothing calls this directly

Calls 5

executeCommandMethod · 0.95
newGroupMemberFunction · 0.85
tInfoFunction · 0.85
newProjectMemberFunction · 0.85
printFlagsTableFunction · 0.85

Tested by

no test coverage detected