TestDeriveRunClassification tests the classification mapping helper.
(t *testing.T)
| 882 | |
| 883 | // TestDeriveRunClassification tests the classification mapping helper. |
| 884 | func TestDeriveRunClassification(t *testing.T) { |
| 885 | tests := []struct { |
| 886 | name string |
| 887 | comparison *AuditComparisonData |
| 888 | want string |
| 889 | }{ |
| 890 | { |
| 891 | name: "nil comparison returns unclassified", |
| 892 | comparison: nil, |
| 893 | want: "unclassified", |
| 894 | }, |
| 895 | { |
| 896 | name: "no baseline found returns baseline", |
| 897 | comparison: &AuditComparisonData{BaselineFound: false}, |
| 898 | want: "baseline", |
| 899 | }, |
| 900 | { |
| 901 | name: "nil classification with baseline returns unclassified", |
| 902 | comparison: &AuditComparisonData{ |
| 903 | BaselineFound: true, |
| 904 | Classification: nil, |
| 905 | }, |
| 906 | want: "unclassified", |
| 907 | }, |
| 908 | { |
| 909 | name: "risky label returns risky", |
| 910 | comparison: &AuditComparisonData{ |
| 911 | BaselineFound: true, |
| 912 | Classification: &AuditComparisonClassification{Label: "risky"}, |
| 913 | }, |
| 914 | want: "risky", |
| 915 | }, |
| 916 | { |
| 917 | name: "stable label returns normal", |
| 918 | comparison: &AuditComparisonData{ |
| 919 | BaselineFound: true, |
| 920 | Classification: &AuditComparisonClassification{Label: "stable"}, |
| 921 | }, |
| 922 | want: "normal", |
| 923 | }, |
| 924 | { |
| 925 | name: "changed label returns normal", |
| 926 | comparison: &AuditComparisonData{ |
| 927 | BaselineFound: true, |
| 928 | Classification: &AuditComparisonClassification{Label: "changed"}, |
| 929 | }, |
| 930 | want: "normal", |
| 931 | }, |
| 932 | } |
| 933 | |
| 934 | for _, tt := range tests { |
| 935 | t.Run(tt.name, func(t *testing.T) { |
| 936 | got := deriveRunClassification(tt.comparison) |
| 937 | if got != tt.want { |
| 938 | t.Errorf("deriveRunClassification() = %q, want %q", got, tt.want) |
| 939 | } |
| 940 | }) |
| 941 | } |
nothing calls this directly
no test coverage detected