MCPcopy Create free account
hub / github.com/github/gh-aw / TestDeriveRunClassification

Function TestDeriveRunClassification

pkg/cli/logs_report_test.go:884–942  ·  view source on GitHub ↗

TestDeriveRunClassification tests the classification mapping helper.

(t *testing.T)

Source from the content-addressed store, hash-verified

882
883// TestDeriveRunClassification tests the classification mapping helper.
884func 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 }

Callers

nothing calls this directly

Calls 3

deriveRunClassificationFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected