Skip to content

Commit 4590cd1

Browse files
committed
add test validating schema with gojsonschema
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 8bebd9c commit 4590cd1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: schema/compose-spec.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft-07/schema",
33
"$id": "compose_spec.json",
44
"type": "object",
55
"title": "Compose Specification",

Diff for: schema/schema_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package schema
1818

1919
import (
2020
"os"
21+
"path/filepath"
2122
"testing"
2223

24+
"github.com/xeipuuv/gojsonschema"
2325
"gopkg.in/yaml.v3"
2426
"gotest.tools/v3/assert"
2527
)
@@ -251,3 +253,14 @@ func TestValidateVariables(t *testing.T) {
251253
assert.NilError(t, err)
252254
assert.NilError(t, Validate(config))
253255
}
256+
257+
func TestSchema(t *testing.T) {
258+
abs, err := filepath.Abs("compose-spec.json")
259+
assert.NilError(t, err)
260+
schema := gojsonschema.NewReferenceLoader("file:///" + abs)
261+
sl := gojsonschema.NewSchemaLoader()
262+
sl.Draft = gojsonschema.Draft7
263+
sl.Validate = true
264+
_, err = sl.Compile(schema)
265+
assert.NilError(t, err)
266+
}

0 commit comments

Comments
 (0)