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

Function TestProtectBranch

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

Source from the content-addressed store, hash-verified

28)
29
30func TestProtectBranch(t *testing.T) {
31 tt := []struct {
32 name string
33 flagsMap map[string]string
34 args []string
35 expect testResult
36 expectOut []string
37 }{
38 {
39 name: "protect an existing branch",
40 flagsMap: map[string]string{
41 "project": "12",
42 "protect": "true",
43 "dev-can-push": "true",
44 "dev-can-merge": "true",
45 "out": "json",
46 },
47 args: []string{"release-abc"}, // to be created in SETUP
48 expect: pass,
49 expectOut: []string{
50 `"protected": true`,
51 `"developers_can_push": true`,
52 `"developers_can_merge": true`,
53 },
54 },
55 {
56 name: "protect non existing branch fails",
57 flagsMap: map[string]string{
58 "project": "12",
59 "protect": "true",
60 },
61 args: []string{"xxxx"},
62 expect: fail,
63 expectOut: []string{`message: 404 Branch Not Found`},
64 },
65 {
66 name: "unprotect an existing branch",
67 flagsMap: map[string]string{
68 "project": "12",
69 "unprotect": "true",
70 "out": "json",
71 },
72 args: []string{"master"},
73 expect: pass,
74 expectOut: []string{
75 `"protected": false`,
76 `"developers_can_push": false`,
77 `"developers_can_merge": false`,
78 },
79 },
80 {
81 name: "invalid usage of flags fails",
82 flagsMap: map[string]string{
83 "project": "12",
84 "dev-can-merge": "true",
85 },
86 args: []string{"master"},
87 expect: fail,

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected