Add schema selection values and ownership
This commit is contained in:
@@ -85,3 +85,34 @@ func TestValidateOutputContract(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchemaSelection(t *testing.T) {
|
||||
file, blank := "schema.json", " "
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
schema any
|
||||
file *string
|
||||
path string
|
||||
valid bool
|
||||
}{
|
||||
{"missing", nil, nil, "", false},
|
||||
{"false", false, nil, "", true},
|
||||
{"true", true, nil, "", true},
|
||||
{"empty object", map[string]any{}, nil, "", true},
|
||||
{"file", nil, &file, "", true},
|
||||
{"blank file", nil, &blank, "", false},
|
||||
{"conflict", false, &file, "", false},
|
||||
{"path conflict", map[string]any{}, nil, "schema.json", false},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
contract := OutputContract{Format: FormatJSON, ValidationMode: ValidationJSONSchema, Schema: tt.schema, SchemaFile: tt.file, SchemaPath: tt.path}
|
||||
if err := ValidateOutputContract(contract); (err == nil) != tt.valid {
|
||||
t.Fatalf("active selection error = %v", err)
|
||||
}
|
||||
contract.ValidationMode = ValidationNone
|
||||
if err := ValidateOutputContract(contract); err != nil {
|
||||
t.Fatalf("inactive selection: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user