[chore] Add test to check all versioned detectors are non-zero (#2272)

This commit is contained in:
Miccah
2024-01-05 12:06:59 -08:00
committed by GitHub
parent 241e153dfb
commit 5e78ad402e
+17
View File
@@ -48,3 +48,20 @@ func TestDefaultDetectorTypesImplementing(t *testing.T) {
)
}
}
func TestDefaultVersionerDetectorsHaveNonZeroVersions(t *testing.T) {
// Loop through all our default detectors and find the ones that
// implement Versioner. Of those, check each version is not zero.
// This is required due to an implementation detail of filtering detectors.
// See: https://github.com/trufflesecurity/trufflehog/blob/v3.63.7/main.go#L624-L638
for _, detector := range DefaultDetectors() {
v, ok := detector.(detectors.Versioner)
if !ok || v.Version() != 0 {
continue
}
t.Errorf(
"detector %q implements Versioner that returns a zero version",
detectorspb.DetectorType_name[int32(detector.Type())],
)
}
}