(t *testing.T)
| 670 | } |
| 671 | |
| 672 | func TestProcessOutputForImageValidation(t *testing.T) { |
| 673 | tests := []struct { |
| 674 | name string |
| 675 | out *output.Output |
| 676 | err error |
| 677 | comp app.SnapshotComponent |
| 678 | showSuccesses bool |
| 679 | outputFormats []string |
| 680 | expectedSuccess bool |
| 681 | }{ |
| 682 | { |
| 683 | name: "successful validation", |
| 684 | out: &output.Output{ |
| 685 | ImageURL: "registry.com/image:tag", |
| 686 | PolicyInput: []byte("policy input"), |
| 687 | }, |
| 688 | err: nil, |
| 689 | comp: app.SnapshotComponent{ |
| 690 | Name: "component1", |
| 691 | ContainerImage: "registry.com/image:tag", |
| 692 | }, |
| 693 | showSuccesses: false, |
| 694 | outputFormats: []string{}, |
| 695 | expectedSuccess: true, |
| 696 | }, |
| 697 | { |
| 698 | name: "validation with violations", |
| 699 | out: &output.Output{ |
| 700 | ImageURL: "registry.com/image:tag", |
| 701 | PolicyInput: []byte("policy input"), |
| 702 | PolicyCheck: []evaluator.Outcome{ |
| 703 | { |
| 704 | Failures: []evaluator.Result{ |
| 705 | {Message: "violation1"}, |
| 706 | }, |
| 707 | }, |
| 708 | }, |
| 709 | }, |
| 710 | err: nil, |
| 711 | comp: app.SnapshotComponent{ |
| 712 | Name: "component1", |
| 713 | ContainerImage: "registry.com/image:tag", |
| 714 | }, |
| 715 | showSuccesses: false, |
| 716 | outputFormats: []string{}, |
| 717 | expectedSuccess: false, |
| 718 | }, |
| 719 | { |
| 720 | name: "validation error", |
| 721 | out: nil, |
| 722 | err: errors.New("validation failed"), |
| 723 | comp: app.SnapshotComponent{ |
| 724 | Name: "component1", |
| 725 | ContainerImage: "registry.com/image:tag", |
| 726 | }, |
| 727 | showSuccesses: false, |
| 728 | outputFormats: []string{}, |
| 729 | expectedSuccess: false, |
nothing calls this directly
no test coverage detected