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

Function TestNewUser

cmd/new_user_test.go:28–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestNewUser(t *testing.T) {
29 tt := []struct {
30 name string
31 flagsMap map[string]string
32 args []string
33 expect testResult
34 }{
35 {
36 name: "create user using all possible flags",
37 flagsMap: map[string]string{
38 "name": "john.swagger",
39 "email": "john.swagger@example.com",
40 "password": "12345678",
41 "reset-password": "false",
42 "external": "false",
43 "admin": "false",
44 "can-create-group": "false",
45 "skip-confirmation": "true",
46 "skype": "john.swagger",
47 "linkedin": "john.swagger",
48 "twitter": "john.swagger",
49 "website-url": "john.swagger.com",
50 "org": "john.swagger org",
51 "external-uid": "john.swagger",
52 "provider": "github",
53 "bio": "like a sir",
54 "location": "london",
55 "projects-limit": "5",
56 },
57 args: []string{"john.swagger"},
58 expect: pass,
59 },
60 }
61
62 for _, tc := range tt {
63 t.Run(tc.name, func(t *testing.T) {
64 // SETUP
65 // Ensure that the user to be created is deleted
66 if tc.expect == pass {
67 if err := deleteUser(tc.args[0]); err != nil {
68 tInfo(err)
69 } else {
70 // sleep for at least 3 seconds to ensure that user is deleted
71 time.Sleep(3 * time.Second)
72 }
73 }
74
75 execT := execTestCmdFlags{
76 t: t,
77 cmd: newUserCmd,
78 flagsMap: tc.flagsMap,
79 args: tc.args,
80 }
81
82 stdout, execResult := execT.executeCommand()
83 assertEqualResult(t, execResult, tc.expect, printFlagsTable(tc.flagsMap, stdout))
84 if tc.expect == pass {
85 assertOutContains(t, stdout, tc.args[0])

Callers

nothing calls this directly

Calls 6

executeCommandMethod · 0.95
deleteUserFunction · 0.85
tInfoFunction · 0.85
assertEqualResultFunction · 0.85
printFlagsTableFunction · 0.85
assertOutContainsFunction · 0.85

Tested by

no test coverage detected