(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestContainsOutputFormat(t *testing.T) { |
| 326 | tests := []struct { |
| 327 | name string |
| 328 | outputFormats []string |
| 329 | format string |
| 330 | expected bool |
| 331 | }{ |
| 332 | { |
| 333 | name: "format exists without path", |
| 334 | outputFormats: []string{"json", "yaml", "text"}, |
| 335 | format: "json", |
| 336 | expected: true, |
| 337 | }, |
| 338 | { |
| 339 | name: "format exists with path", |
| 340 | outputFormats: []string{"json=/path/to/file.json", "yaml", "text"}, |
| 341 | format: "json", |
| 342 | expected: true, |
| 343 | }, |
| 344 | { |
| 345 | name: "format does not exist", |
| 346 | outputFormats: []string{"json", "yaml", "text"}, |
| 347 | format: "xml", |
| 348 | expected: false, |
| 349 | }, |
| 350 | { |
| 351 | name: "empty formats", |
| 352 | outputFormats: []string{}, |
| 353 | format: "json", |
| 354 | expected: false, |
| 355 | }, |
| 356 | { |
| 357 | name: "format with multiple equals", |
| 358 | outputFormats: []string{"attestation=/path/to/file=with=equals"}, |
| 359 | format: "attestation", |
| 360 | expected: true, |
| 361 | }, |
| 362 | { |
| 363 | name: "format in middle of list", |
| 364 | outputFormats: []string{"json", "attestation=/path/to/file", "yaml"}, |
| 365 | format: "attestation", |
| 366 | expected: true, |
| 367 | }, |
| 368 | { |
| 369 | name: "case sensitive match", |
| 370 | outputFormats: []string{"JSON", "yaml"}, |
| 371 | format: "json", |
| 372 | expected: false, |
| 373 | }, |
| 374 | } |
| 375 | |
| 376 | for _, tt := range tests { |
| 377 | t.Run(tt.name, func(t *testing.T) { |
| 378 | result := ContainsOutputFormat(tt.outputFormats, tt.format) |
| 379 | assert.Equal(t, tt.expected, result) |
| 380 | }) |
| 381 | } |
| 382 | } |
nothing calls this directly
no test coverage detected