Exemple #1
0
func TestFeaturesDetector(t *testing.T, detector detectors.FeaturesDetector, tests []FeatureVersionTest) {
	for _, test := range tests {
		featureVersions, err := detector.Detect(test.Data)
		if assert.Nil(t, err) && assert.Len(t, featureVersions, len(test.FeatureVersions)) {
			for _, expectedFeatureVersion := range test.FeatureVersions {
				assert.Contains(t, featureVersions, expectedFeatureVersion)
			}
		}
	}
}
Exemple #2
0
// TestDetector runs a detector on each provided instance of TestData and
// asserts the ouput to be equal to the expected output.
func TestDetector(t *testing.T, detector detectors.FeaturesDetector, testData []TestData) {
	for _, td := range testData {
		featureVersions, err := detector.Detect(td.Data)
		if assert.Nil(t, err) && assert.Len(t, featureVersions, len(td.FeatureVersions)) {
			for _, expectedFeatureVersion := range td.FeatureVersions {
				assert.Contains(t, featureVersions, expectedFeatureVersion)
			}
		}
	}
}