(t *testing.T)
| 553 | } |
| 554 | |
| 555 | func TestWriteReport(t *testing.T) { |
| 556 | ctx := context.Background() |
| 557 | |
| 558 | // Create a minimal policy with a public key to avoid keyless workflow validation |
| 559 | testPolicy, err := policy.NewPolicy(ctx, policy.Options{ |
| 560 | EffectiveTime: "now", |
| 561 | PublicKey: "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAECBtqKHcvxYkGx7ZXqps3nrYS+ZSA\nmh3m1MZfTGlnr2oN0z+sBWEC23s4RkVSXkEydI6SLYatUtJK8OmiBRS+Xw==\n-----END PUBLIC KEY-----", |
| 562 | }) |
| 563 | require.NoError(t, err) |
| 564 | |
| 565 | tests := []struct { |
| 566 | name string |
| 567 | data ReportData |
| 568 | opts ReportOutputOptions |
| 569 | expectError bool |
| 570 | }{ |
| 571 | { |
| 572 | name: "successful report creation", |
| 573 | data: ReportData{ |
| 574 | Snapshot: "test-snapshot", |
| 575 | Components: []applicationsnapshot.Component{ |
| 576 | { |
| 577 | SnapshotComponent: app.SnapshotComponent{ |
| 578 | Name: "comp1", |
| 579 | ContainerImage: "registry.com/image:tag", |
| 580 | }, |
| 581 | Success: true, |
| 582 | }, |
| 583 | }, |
| 584 | Policy: testPolicy, |
| 585 | PolicyInputs: [][]byte{[]byte("input1")}, |
| 586 | Expansion: nil, |
| 587 | ShowSuccesses: false, |
| 588 | ShowWarnings: true, |
| 589 | }, |
| 590 | opts: ReportOutputOptions{ |
| 591 | Output: []string{}, |
| 592 | NoColor: false, |
| 593 | ForceColor: false, |
| 594 | }, |
| 595 | expectError: false, |
| 596 | }, |
| 597 | { |
| 598 | name: "report with output formats", |
| 599 | data: ReportData{ |
| 600 | Snapshot: "test-snapshot", |
| 601 | Components: []applicationsnapshot.Component{ |
| 602 | { |
| 603 | SnapshotComponent: app.SnapshotComponent{ |
| 604 | Name: "comp1", |
| 605 | ContainerImage: "registry.com/image:tag", |
| 606 | }, |
| 607 | Success: true, |
| 608 | }, |
| 609 | }, |
| 610 | Policy: testPolicy, |
| 611 | PolicyInputs: [][]byte{[]byte("input1")}, |
| 612 | Expansion: nil, |
nothing calls this directly
no test coverage detected