(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestNewBranch(t *testing.T) { |
| 29 | tt := []struct { |
| 30 | name string |
| 31 | flagsMap map[string]string |
| 32 | args []string |
| 33 | expect testResult |
| 34 | }{ |
| 35 | { |
| 36 | name: "create a new branch", |
| 37 | flagsMap: map[string]string{ |
| 38 | "project": "Group2/project12", |
| 39 | "ref": "master", |
| 40 | }, |
| 41 | args: []string{"release-xy"}, |
| 42 | expect: pass, |
| 43 | }, |
| 44 | { |
| 45 | name: "flags must be required", |
| 46 | args: []string{"master"}, |
| 47 | expect: fail, |
| 48 | }, |
| 49 | } |
| 50 | |
| 51 | for _, tc := range tt { |
| 52 | t.Run(tc.name, func(t *testing.T) { |
| 53 | execT := execTestCmdFlags{ |
| 54 | t: t, |
| 55 | cmd: newBranchCmd, |
| 56 | flagsMap: tc.flagsMap, |
| 57 | args: tc.args, |
| 58 | } |
| 59 | stdout, execResult := execT.executeCommand() |
| 60 | fmt.Println(stdout) |
| 61 | assertEqualResult(t, execResult, tc.expect, printFlagsTable(tc.flagsMap, stdout)) |
| 62 | if tc.expect == pass { |
| 63 | assertOutContains(t, stdout, tc.args[0]) |
| 64 | if err := deleteBranch(tc.flagsMap["project"], tc.args[0]); err != nil { |
| 65 | tInfo(err) |
| 66 | } |
| 67 | } |
| 68 | }) |
| 69 | } |
| 70 | } |
nothing calls this directly
no test coverage detected