-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revisit
metaschema
command tests (#160)
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
10 changed files
with
126 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
mkdir "$TMP/schemas" | ||
|
||
cat << 'EOF' > "$TMP/schemas/schema_1.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "string" | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/schemas/schema_2.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": 1 | ||
} | ||
EOF | ||
|
||
"$1" metaschema "$TMP/schemas" 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
fail: $(realpath "$TMP")/schemas/schema_2.json | ||
error: Schema validation failure | ||
The string value "object" was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string" | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/0/\$ref/enum" | ||
The string value was expected to validate against the statically referenced schema | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/0/\$ref" | ||
The value was expected to be of type array but it was of type string | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/1/type" | ||
The string value was expected to validate against at least one of the 2 given subschemas | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf" | ||
The object value was expected to validate against the 33 defined properties subschemas | ||
at instance location "" | ||
at evaluate path "/properties" | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": 1 | ||
} | ||
EOF | ||
|
||
"$1" metaschema "$TMP/schema.json" 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
fail: $(realpath "$TMP")/schema.json | ||
error: Schema validation failure | ||
The string value "object" was expected to equal one of the following values: "array", "boolean", "integer", "null", "number", "object", and "string" | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/0/\$ref/enum" | ||
The string value was expected to validate against the statically referenced schema | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/0/\$ref" | ||
The value was expected to be of type array but it was of type string | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf/1/type" | ||
The string value was expected to validate against at least one of the 2 given subschemas | ||
at instance location "/type" | ||
at evaluate path "/properties/type/anyOf" | ||
The object value was expected to validate against the 33 defined properties subschemas | ||
at instance location "" | ||
at evaluate path "/properties" | ||
EOF | ||
|
||
diff "$TMP/stderr.txt" "$TMP/expected.txt" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.