Add schema selection values and ownership

This commit is contained in:
2026-11-20 15:20:29 +00:00
parent e775a3c116
commit fbe3d427a2
17 changed files with 186 additions and 9 deletions

View File

@@ -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)
}
})
}
}