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

Function TestDeleteProject

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

Source from the content-addressed store, hash-verified

29)
30
31func TestDeleteProject(t *testing.T) {
32 tt := []struct {
33 name string
34 args []string
35 expect testResult
36 }{
37 {
38 name: "successfully delete a project",
39 // NOTE: this will be created under root/
40 args: []string{"DeleteThisProject"},
41 expect: pass,
42 },
43 {
44 name: "deleting a non existent project should fail",
45 args: []string{"UnknownProject"},
46 expect: fail,
47 },
48 }
49
50 for _, tc := range tt {
51 t.Run(tc.name, func(t *testing.T) {
52 // NOTE: Setup for positive test
53 // Create the project to delete
54 if tc.expect == pass {
55 _, err := newProject(&gitlab.CreateProjectOptions{
56 Name: gitlab.String(tc.args[0]),
57 Path: gitlab.String(tc.args[0]),
58 })
59 if err != nil {
60 tInfo(fmt.Sprintf("failed to create project %s", tc.args[0]))
61 }
62 // NOTE: the test data is created under root/ as noted above
63 tc.args[0] = "root/" + tc.args[0]
64 }
65
66 execT := execTestCmdFlags{
67 t: t,
68 cmd: deleteProjectCmd,
69 args: tc.args,
70 }
71 stdout, execResult := execT.executeCommand()
72 require.Equal(t, tc.expect, execResult, stdout)
73
74 // NOTE: assert positive test
75 // Validate the command output
76 if tc.expect == pass {
77 require.Contains(t, stdout, "has been deleted")
78 }
79 })
80 }
81}

Callers

nothing calls this directly

Calls 3

executeCommandMethod · 0.95
newProjectFunction · 0.85
tInfoFunction · 0.85

Tested by

no test coverage detected