TestMissingToolReportAsFailureConfig verifies the report-as-failure field behavior.
(t *testing.T)
| 369 | |
| 370 | // TestMissingToolReportAsFailureConfig verifies the report-as-failure field behavior. |
| 371 | func TestMissingToolReportAsFailureConfig(t *testing.T) { |
| 372 | compiler := NewCompiler() |
| 373 | |
| 374 | tests := []struct { |
| 375 | name string |
| 376 | configData map[string]any |
| 377 | expectReportAsFailure *string |
| 378 | }{ |
| 379 | { |
| 380 | name: "Default (nil value) - report-as-failure defaults to true", |
| 381 | configData: map[string]any{"missing-tool": nil}, |
| 382 | expectReportAsFailure: strPtr("true"), |
| 383 | }, |
| 384 | { |
| 385 | name: "Map config without report-as-failure key - defaults to true", |
| 386 | configData: map[string]any{ |
| 387 | "missing-tool": map[string]any{"max": 3}, |
| 388 | }, |
| 389 | expectReportAsFailure: strPtr("true"), |
| 390 | }, |
| 391 | { |
| 392 | name: "report-as-failure explicitly false", |
| 393 | configData: map[string]any{ |
| 394 | "missing-tool": map[string]any{"report-as-failure": false}, |
| 395 | }, |
| 396 | expectReportAsFailure: strPtr("false"), |
| 397 | }, |
| 398 | { |
| 399 | name: "report-as-failure explicitly true", |
| 400 | configData: map[string]any{ |
| 401 | "missing-tool": map[string]any{"report-as-failure": true}, |
| 402 | }, |
| 403 | expectReportAsFailure: strPtr("true"), |
| 404 | }, |
| 405 | { |
| 406 | name: "report-as-failure as expression", |
| 407 | configData: map[string]any{ |
| 408 | "missing-tool": map[string]any{"report-as-failure": "${{ inputs.report-as-failure }}"}, |
| 409 | }, |
| 410 | expectReportAsFailure: strPtr("${{ inputs.report-as-failure }}"), |
| 411 | }, |
| 412 | } |
| 413 | |
| 414 | for _, tt := range tests { |
| 415 | t.Run(tt.name, func(t *testing.T) { |
| 416 | config := compiler.parseMissingToolConfig(tt.configData) |
| 417 | if tt.expectReportAsFailure == nil { |
| 418 | if config != nil && config.ReportAsFailure != nil { |
| 419 | t.Errorf("Expected report-as-failure nil, got %q", *config.ReportAsFailure) |
| 420 | } |
| 421 | } else { |
| 422 | if config == nil { |
| 423 | t.Fatal("Expected non-nil config") |
| 424 | } |
| 425 | if config.ReportAsFailure == nil { |
| 426 | t.Errorf("Expected report-as-failure %q, got nil", *tt.expectReportAsFailure) |
| 427 | } else if *config.ReportAsFailure != *tt.expectReportAsFailure { |
| 428 | t.Errorf("Expected report-as-failure %q, got %q", *tt.expectReportAsFailure, *config.ReportAsFailure) |
nothing calls this directly
no test coverage detected