Unify inline and bound schema preparation
This commit is contained in:
@@ -3,6 +3,7 @@ package validate
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -29,9 +30,9 @@ func TestSchemaPreparationDoesNotDependOnSourceName(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fsys := fstest.MapFS{"schema.json": &fstest.MapFile{Data: []byte(test.schema)}}
|
||||
for i, validator := range []ValidationPreparer{NewStandardValidator(dir), NewFSValidator(fsys, ".")} {
|
||||
for i, source := range []fs.FS{os.DirFS(dir), fsys} {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
_, err := validator.PrepareValidation(context.Background(), domain.OutputContract{Format: domain.FormatJSON, ValidationMode: domain.ValidationJSONSchema, SchemaPath: "schema.json"})
|
||||
_, err := NewValidator().PrepareValidation(context.Background(), Input{Contract: domain.OutputContract{Format: domain.FormatJSON, ValidationMode: domain.ValidationJSONSchema, SchemaPath: "schema.json"}, File: &domain.ResourceBinding{FS: source, Path: "schema.json"}})
|
||||
if test.rejected {
|
||||
if err == nil || !strings.Contains(err.Error(), "source location") {
|
||||
t.Fatalf("expected source-independent rejection, got %v", err)
|
||||
|
||||
Reference in New Issue
Block a user