Share self-contained schema compilation

This commit is contained in:
2026-11-05 13:56:03 +00:00
parent 1e122f0473
commit e056cb1607
4 changed files with 60 additions and 205 deletions

View File

@@ -35,14 +35,13 @@ func TestValidationCancellationBeforeWorkDoesNotOpenSchemaSource(t *testing.T) {
}
}
func TestValidationCancellationBetweenReferencedSchemaReadChunks(t *testing.T) {
func TestValidationCancellationBetweenRootSchemaReadChunks(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
source := &controlledSchemaFS{
FS: fstest.MapFS{
"root.json": {Data: []byte(`{"$ref":"child.json"}`)},
"child.json": {Data: []byte(`{"type":"string"}` + strings.Repeat(" ", schemaReadChunkSize*2))},
"root.json": {Data: []byte(`{"type":"string"}` + strings.Repeat(" ", schemaReadChunkSize*2))},
},
target: "child.json",
target: "root.json",
cancel: cancel,
}
validator := NewFSValidator(source, ".")
@@ -57,8 +56,8 @@ func TestValidationCancellationBetweenReferencedSchemaReadChunks(t *testing.T) {
if reads := source.reads.Load(); reads != 1 {
t.Fatalf("controlled child reads = %d, want 1", reads)
}
if closes := source.closes.Load(); closes != 1 {
t.Fatalf("controlled child closes = %d, want 1", closes)
if closes := source.closes.Load(); closes != 2 {
t.Fatalf("controlled root closes = %d, want stat and read handles closed", closes)
}
}