Share self-contained schema compilation
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user