Unify inline and bound schema preparation
This commit is contained in:
@@ -19,14 +19,14 @@ func TestValidationCancellationBeforeWorkDoesNotOpenSchemaSource(t *testing.T) {
|
||||
source := &countingSchemaFS{FS: fstest.MapFS{
|
||||
"schema.json": {Data: []byte(`{"type":"object"}`)},
|
||||
}}
|
||||
validator := NewFSValidator(source, ".")
|
||||
validator := NewValidator()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
plan, err := validator.PrepareValidation(ctx, domain.OutputContract{
|
||||
plan, err := validator.PrepareValidation(ctx, Input{Contract: domain.OutputContract{
|
||||
ValidationMode: domain.ValidationJSONSchema,
|
||||
SchemaPath: "schema.json",
|
||||
})
|
||||
}, File: &domain.ResourceBinding{FS: source, Path: "schema.json"}})
|
||||
if plan != nil || !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("PrepareValidation() = (%v, %v), want nil plan and context cancellation", plan, err)
|
||||
}
|
||||
@@ -44,20 +44,20 @@ func TestValidationCancellationBetweenRootSchemaReadChunks(t *testing.T) {
|
||||
target: "root.json",
|
||||
cancel: cancel,
|
||||
}
|
||||
validator := NewFSValidator(source, ".")
|
||||
validator := NewValidator()
|
||||
|
||||
plan, err := validator.PrepareValidation(ctx, domain.OutputContract{
|
||||
plan, err := validator.PrepareValidation(ctx, Input{Contract: domain.OutputContract{
|
||||
ValidationMode: domain.ValidationJSONSchema,
|
||||
SchemaPath: "root.json",
|
||||
})
|
||||
}, File: &domain.ResourceBinding{FS: source, Path: "root.json"}})
|
||||
if plan != nil || !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("PrepareValidation() = (%v, %v), want nil plan and context cancellation", plan, err)
|
||||
}
|
||||
if reads := source.reads.Load(); reads != 1 {
|
||||
t.Fatalf("controlled child reads = %d, want 1", reads)
|
||||
}
|
||||
if closes := source.closes.Load(); closes != 2 {
|
||||
t.Fatalf("controlled root closes = %d, want stat and read handles closed", closes)
|
||||
if closes := source.closes.Load(); closes != 1 {
|
||||
t.Fatalf("controlled root closes = %d, want read handle closed", closes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,17 +112,17 @@ func TestCancellationDoesNotDetachBlockedSchemaRead(t *testing.T) {
|
||||
started: started,
|
||||
release: release,
|
||||
}
|
||||
validator := NewFSValidator(source, ".")
|
||||
validator := NewValidator()
|
||||
type outcome struct {
|
||||
plan PreparedValidation
|
||||
err error
|
||||
}
|
||||
result := make(chan outcome, 1)
|
||||
go func() {
|
||||
plan, err := validator.PrepareValidation(ctx, domain.OutputContract{
|
||||
plan, err := validator.PrepareValidation(ctx, Input{Contract: domain.OutputContract{
|
||||
ValidationMode: domain.ValidationJSONSchema,
|
||||
SchemaPath: "schema.json",
|
||||
})
|
||||
}, File: &domain.ResourceBinding{FS: source, Path: "schema.json"}})
|
||||
result <- outcome{plan: plan, err: err}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user