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

Function TestNewRelease

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

Source from the content-addressed store, hash-verified

29)
30
31func TestNewRelease(t *testing.T) {
32 tt := []struct {
33 name string
34 flagsMap map[string]string
35 args []string
36 expect testResult
37 }{
38 {
39 name: "no flags should fail",
40 args: []string{"sample_1.0"},
41 expect: fail,
42 },
43 {
44 name: "create a new release successfully",
45 flagsMap: map[string]string{
46 "project": "Group1/project1",
47 "description": "Sample",
48 },
49 args: []string{"v2.0-alpha"},
50 expect: pass,
51 },
52 {
53 name: "no arg should fail",
54 flagsMap: map[string]string{
55 "project": "Group1/project1",
56 "description": "Sample",
57 },
58 expect: fail,
59 },
60 }
61
62 for _, tc := range tt {
63 // SETUP
64 if tc.expect == pass {
65 // Ensure to delete the tag/release
66 err := deleteTag(tc.flagsMap["project"], tc.args[0])
67 tInfo(err)
68 // Ensure to create a tag for the release
69 _, err = newTag(tc.flagsMap["project"],
70 &gitlab.CreateTagOptions{
71 TagName: gitlab.String(tc.args[0]),
72 Ref: gitlab.String("master"),
73 })
74 if err != nil {
75 if !strings.Contains(err.Error(), "message: Release already exists") {
76 t.Fatalf("Can't create test data: %v\n", err)
77 }
78 }
79 }
80 t.Run(tc.name, func(t *testing.T) {
81 execT := execTestCmdFlags{
82 t: t,
83 cmd: newReleaseCmd,
84 flagsMap: tc.flagsMap,
85 args: tc.args,
86 }
87 stdout, execResult := execT.executeCommand()
88 fmt.Println(stdout)

Callers

nothing calls this directly

Calls 6

executeCommandMethod · 0.95
deleteTagFunction · 0.85
tInfoFunction · 0.85
newTagFunction · 0.85
assertEqualResultFunction · 0.85
printFlagsTableFunction · 0.85

Tested by

no test coverage detected