MCPcopy Create free account
hub / github.com/devopsctl/gitlabctl / TestDeleteBranchCmd

Function TestDeleteBranchCmd

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

Source from the content-addressed store, hash-verified

26)
27
28func TestDeleteBranchCmd(t *testing.T) {
29 tt := []struct {
30 name string
31 flagsMap map[string]string
32 args []string
33 expect testResult
34 }{
35 {
36 name: "delete an existent branch",
37 flagsMap: map[string]string{
38 "project": "Group2/project12",
39 },
40 args: []string{"feature-x"},
41 expect: pass,
42 },
43 {
44 name: "delete a non existent branch fails",
45 flagsMap: map[string]string{
46 "project": "Group2/project12",
47 },
48 args: []string{"nil-branch"},
49 expect: fail,
50 },
51 }
52
53 for _, tc := range tt {
54 // SETUP
55 // Create branch before deleting
56 if tc.expect == pass {
57 if _, err := newBranch(tc.flagsMap["project"],
58 &gitlab.CreateBranchOptions{
59 Branch: gitlab.String(tc.args[0]),
60 Ref: gitlab.String("master"),
61 }); err != nil {
62 tInfo(err)
63 }
64 }
65 t.Run(tc.name, func(t *testing.T) {
66 execT := execTestCmdFlags{
67 t: t,
68 cmd: deleteBranchCmd,
69 flagsMap: tc.flagsMap,
70 args: tc.args,
71 }
72 stdout, execResult := execT.executeCommand()
73 assertEqualResult(t, execResult, tc.expect, printFlagsTable(tc.flagsMap, stdout))
74 })
75 }
76
77}

Callers

nothing calls this directly

Calls 5

executeCommandMethod · 0.95
newBranchFunction · 0.85
tInfoFunction · 0.85
assertEqualResultFunction · 0.85
printFlagsTableFunction · 0.85

Tested by

no test coverage detected