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

Function TestNewMember

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

Source from the content-addressed store, hash-verified

27)
28
29func TestNewMember(t *testing.T) {
30 tt := []struct {
31 name string
32 args []string
33 flagsMap map[string]string
34 expect testResult
35 expectOut string
36 }{
37 {
38 name: "add a member using username to a project",
39 args: []string{"kevin.mclean"},
40 flagsMap: map[string]string{
41 "from-project": "Group1/Project1",
42 "expires-at": "2069-06-09",
43 "access-level": "10",
44 },
45 expect: pass,
46 },
47 {
48 name: "add a member using username to a group",
49 args: []string{"amelia.walsh"},
50 flagsMap: map[string]string{
51 "from-group": "Group1",
52 "expires-at": "2069-06-09",
53 "access-level": "30",
54 },
55 expect: pass,
56 },
57 {
58 name: "missing required flag fails",
59 args: []string{"amelia.walsh"},
60 expect: fail,
61 expectOut: fmt.Sprint(setAtLeastOneFlagError),
62 },
63 {
64 name: "using invalid access level flag value fails",
65 args: []string{"john.doe"},
66 flagsMap: map[string]string{
67 "from-group": "Group2",
68 "access-level": "21",
69 },
70 expect: fail,
71 expectOut: "not a recognized value of 'access-level' flag",
72 },
73 {
74 name: "using both from-group and from-project fails",
75 args: []string{"amelia.walsh"},
76 flagsMap: map[string]string{
77 "from-group": "Group2",
78 "from-project": "Group2",
79 "access-level": "30",
80 },
81 expect: fail,
82 expectOut: fmt.Sprint(usedMoreThanOneFlagError),
83 },
84 }
85
86 for _, tc := range tt {

Callers

nothing calls this directly

Calls 5

executeCommandMethod · 0.95
deleteGroupMemberFunction · 0.85
tInfoFunction · 0.85
deleteProjectMemberFunction · 0.85
printFlagsTableFunction · 0.85

Tested by

no test coverage detected