Harden the runner contract
This commit is contained in:
@@ -83,6 +83,19 @@ func TestRunRejectsInvalidSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunRejectsNilExtractorFromFactory(t *testing.T) {
|
||||
factory := fakeFactory{extractors: map[string]contracts.Extractor{
|
||||
"generic-extractor": nil,
|
||||
}}
|
||||
|
||||
_, err := New(factory).Run(context.Background(), RunInput{
|
||||
Source: validSourceDocument(),
|
||||
ExtractorKeys: []string{"generic-extractor"},
|
||||
})
|
||||
|
||||
assertRunError(t, err, "returned nil extractor")
|
||||
}
|
||||
|
||||
func TestRunUsesConfiguredExtractorOrderAndAssignsGlobalIndices(t *testing.T) {
|
||||
var order []string
|
||||
var seenIndices []int
|
||||
@@ -251,6 +264,25 @@ func TestRunSurfacesValidatorCardinalityError(t *testing.T) {
|
||||
assertRunError(t, err, "0 decisions for 1 candidates")
|
||||
}
|
||||
|
||||
func TestRunRejectsNilValidator(t *testing.T) {
|
||||
factory := fakeFactory{extractors: map[string]contracts.Extractor{
|
||||
"generic-extractor": fakeExtractor{
|
||||
key: "generic-extractor",
|
||||
artifactType: "generic-artifact",
|
||||
schemaVersion: "v1",
|
||||
candidateCount: 1,
|
||||
validators: []contracts.Validator{nil},
|
||||
},
|
||||
}}
|
||||
|
||||
_, err := New(factory).Run(context.Background(), RunInput{
|
||||
Source: validSourceDocument(),
|
||||
ExtractorKeys: []string{"generic-extractor"},
|
||||
})
|
||||
|
||||
assertRunError(t, err, "validator[0] must not be nil")
|
||||
}
|
||||
|
||||
func TestRunCollectsExtractorAndValidatorWarnings(t *testing.T) {
|
||||
validator := fakeValidator{
|
||||
name: "generic-validator",
|
||||
|
||||
Reference in New Issue
Block a user