(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestDescGroup(t *testing.T) { |
| 30 | setBasicAuthEnvs() |
| 31 | tt := []struct { |
| 32 | name string |
| 33 | flagsMap map[string]string |
| 34 | args []string |
| 35 | expect testResult |
| 36 | }{ |
| 37 | { |
| 38 | name: "print in yaml", |
| 39 | args: []string{"Group1"}, |
| 40 | flagsMap: map[string]string{ |
| 41 | "out": "yaml", |
| 42 | }, |
| 43 | expect: pass, |
| 44 | }, |
| 45 | { |
| 46 | name: "print in json", |
| 47 | args: []string{"Group1"}, |
| 48 | flagsMap: map[string]string{ |
| 49 | "out": "json", |
| 50 | }, |
| 51 | expect: pass, |
| 52 | }, |
| 53 | { |
| 54 | name: "print simple view without flags", |
| 55 | args: []string{"Group1"}, |
| 56 | expect: pass, |
| 57 | }, |
| 58 | { |
| 59 | name: "describe no args should fail", |
| 60 | expect: fail, |
| 61 | }, |
| 62 | { |
| 63 | name: "invalid out flag should fail", |
| 64 | args: []string{"Group1"}, |
| 65 | flagsMap: map[string]string{ |
| 66 | "out": "xxx", |
| 67 | }, |
| 68 | expect: fail, |
| 69 | }, |
| 70 | { |
| 71 | name: "describe non existent group should fail", |
| 72 | args: []string{"XXX"}, |
| 73 | flagsMap: map[string]string{ |
| 74 | // fix the value of the previous out flag |
| 75 | "out": "simple"}, |
| 76 | expect: fail, |
| 77 | }, |
| 78 | } |
| 79 | |
| 80 | for _, tc := range tt { |
| 81 | t.Run(tc.name, func(t *testing.T) { |
| 82 | execT := execTestCmdFlags{ |
| 83 | t: t, |
| 84 | cmd: descGroupCmd, |
| 85 | flagsMap: tc.flagsMap, |
| 86 | args: tc.args, |
nothing calls this directly
no test coverage detected