(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestNewProject(t *testing.T) { |
| 31 | tt := []struct { |
| 32 | name string |
| 33 | flagsMap map[string]string |
| 34 | args []string |
| 35 | expect testResult |
| 36 | }{ |
| 37 | { |
| 38 | name: "create a new project using all flags", |
| 39 | flagsMap: map[string]string{ |
| 40 | "namespace": "Group1", |
| 41 | "desc": "Created by go test", |
| 42 | "issues-enabled": "true", |
| 43 | "merge-requests-enabled": "true", |
| 44 | "jobs-enabled": "true", |
| 45 | "wiki-enabled": "true", |
| 46 | "snippets-enabled": "true", |
| 47 | "resolve-outdated-diff-discussions": "true", |
| 48 | "container-registry-enabled": "true", |
| 49 | "shared-runners-enabled": "true", |
| 50 | "visibility": "private", |
| 51 | "public-jobs": "true", |
| 52 | "only-allow-merge-if-pipeline-succeeds": "true", |
| 53 | "only-allow-merge-if-discussion-are-resolved": "true", |
| 54 | "merge-method": "rebase_merge", |
| 55 | "lfs-enabled": "true", |
| 56 | "request-access-enabled": "true", |
| 57 | "tag-list": "gotest,tdd", |
| 58 | "printing-merge-request-link-enabled": "true", |
| 59 | "ci-config-path": "gitlabci.yml", |
| 60 | "out": "json", |
| 61 | }, |
| 62 | args: []string{"ProjectX"}, |
| 63 | expect: pass, |
| 64 | }, |
| 65 | { |
| 66 | name: "invalid visibility value should fail", |
| 67 | flagsMap: map[string]string{ |
| 68 | "visibility": "xxxx", |
| 69 | }, |
| 70 | args: []string{"ProjectY"}, |
| 71 | expect: fail, |
| 72 | }, |
| 73 | { |
| 74 | name: "invalid merge method value should fail", |
| 75 | flagsMap: map[string]string{ |
| 76 | // fix the visibility value from above tc |
| 77 | "visibility": "private", |
| 78 | "merge-method": "xxxx", |
| 79 | }, |
| 80 | args: []string{"ProjectZ"}, |
| 81 | expect: fail, |
| 82 | }, |
| 83 | } |
| 84 | |
| 85 | for _, tc := range tt { |
| 86 | t.Run(tc.name, func(t *testing.T) { |
| 87 | execT := execTestCmdFlags{ |
nothing calls this directly
no test coverage detected