(t *testing.T)
| 372 | } |
| 373 | |
| 374 | func Test_ReportText_NoResultsSection(t *testing.T) { |
| 375 | // When there are only successes and showSuccesses=false, Results section should not appear |
| 376 | inputs := []Input{ |
| 377 | { |
| 378 | FilePath: "/path/to/file1.yaml", |
| 379 | SuccessCount: 1, |
| 380 | Success: true, |
| 381 | }, |
| 382 | } |
| 383 | ctx := context.Background() |
| 384 | testPolicy := createTestPolicy(t, ctx) |
| 385 | report, err := NewReport(inputs, testPolicy, nil, false, true, true) |
| 386 | assert.NoError(t, err) |
| 387 | |
| 388 | reportText, err := report.toFormat(Text) |
| 389 | assert.NoError(t, err) |
| 390 | textOutput := string(reportText) |
| 391 | |
| 392 | // Results section should not appear when there's nothing to show |
| 393 | assert.Contains(t, textOutput, "Success: true") |
| 394 | assert.Contains(t, textOutput, "Result: SUCCESS") |
| 395 | assert.NotContains(t, textOutput, "Results:") |
| 396 | } |
| 397 | |
| 398 | func createTestPolicy(t *testing.T, ctx context.Context) policy.Policy { |
| 399 | utils.SetTestRekorPublicKey(t) |
nothing calls this directly
no test coverage detected