From 03932a7ac3076709afee870034c3a7c579af6636 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 13 Aug 2024 13:57:40 -0400 Subject: [PATCH] Test compiling schemas with `$ref` (#146) Signed-off-by: Juan Cruz Viotti --- test/CMakeLists.txt | 3 ++- test/compile/{pass.sh => pass_1.sh} | 0 test/compile/pass_2.sh | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) rename test/compile/{pass.sh => pass_1.sh} (100%) create mode 100755 test/compile/pass_2.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5ff74c6..af02126 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -135,7 +135,8 @@ add_jsonschema_test_unix(frame/fail_schema_invalid_json) add_jsonschema_test_unix(frame/fail_unknown_metaschema) # Compile -add_jsonschema_test_unix(compile/pass) +add_jsonschema_test_unix(compile/pass_1) +add_jsonschema_test_unix(compile/pass_2) add_jsonschema_test_unix(compile/fail_no_schema) add_jsonschema_test_unix(compile/fail_schema_invalid_json) add_jsonschema_test_unix(compile/fail_unknown_metaschema) diff --git a/test/compile/pass.sh b/test/compile/pass_1.sh similarity index 100% rename from test/compile/pass.sh rename to test/compile/pass_1.sh diff --git a/test/compile/pass_2.sh b/test/compile/pass_2.sh new file mode 100755 index 0000000..207f3d8 --- /dev/null +++ b/test/compile/pass_2.sh @@ -0,0 +1,19 @@ +#!/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#", + "allOf": [ {"$ref": "#/definitions/job" } ], + "definitions": { "job": {} } +} +EOF + +# We cannot assert on the result as the reference generates a random label +"$1" compile "$TMP/schema.json"