[chore] Add test to check all versioned detectors are non-zero (#2272)
This commit is contained in:
@@ -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())],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user