(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func TestAddFormatFlags(t *testing.T) { |
| 210 | tests := []struct { |
| 211 | name string |
| 212 | args []string |
| 213 | wantsExport *jsonExporter |
| 214 | wantsError string |
| 215 | }{ |
| 216 | { |
| 217 | name: "no format flag", |
| 218 | args: []string{}, |
| 219 | wantsExport: nil, |
| 220 | }, |
| 221 | { |
| 222 | name: "empty format flag", |
| 223 | args: []string{"--format"}, |
| 224 | wantsExport: nil, |
| 225 | wantsError: "flag needs an argument: --format", |
| 226 | }, |
| 227 | { |
| 228 | name: "invalid format field", |
| 229 | args: []string{"--format", "idontexist"}, |
| 230 | wantsExport: nil, |
| 231 | wantsError: "invalid argument \"idontexist\" for \"--format\" flag: valid values are {json}", |
| 232 | }, |
| 233 | { |
| 234 | name: "cannot combine --format with --web", |
| 235 | args: []string{"--format", "json", "--web"}, |
| 236 | wantsExport: nil, |
| 237 | wantsError: "cannot use `--web` with `--format`", |
| 238 | }, |
| 239 | { |
| 240 | name: "cannot use --jq without --format", |
| 241 | args: []string{"--jq", ".number"}, |
| 242 | wantsExport: nil, |
| 243 | wantsError: "cannot use `--jq` without specifying `--format json`", |
| 244 | }, |
| 245 | { |
| 246 | name: "cannot use --template without --format", |
| 247 | args: []string{"--template", "{{.number}}"}, |
| 248 | wantsExport: nil, |
| 249 | wantsError: "cannot use `--template` without specifying `--format json`", |
| 250 | }, |
| 251 | { |
| 252 | name: "with json format", |
| 253 | args: []string{"--format", "json"}, |
| 254 | wantsExport: &jsonExporter{ |
| 255 | filter: "", |
| 256 | template: "", |
| 257 | }, |
| 258 | }, |
| 259 | { |
| 260 | name: "with jq filter", |
| 261 | args: []string{"--format", "json", "-q.number"}, |
| 262 | wantsExport: &jsonExporter{ |
| 263 | filter: ".number", |
| 264 | template: "", |
| 265 | }, |
| 266 | }, |
nothing calls this directly
no test coverage detected