about summary refs log tree commit diff
path: root/pkgs/test/cue
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-12-08 22:19:23 +0100
committerJörg Thalheim <joerg@thalheim.io>2022-12-08 22:19:23 +0100
commit09dcdf4e4e684bebb6d1ee267d0be5d1613ff586 (patch)
tree200a6eba16aa4598ad84bc69952267e5a0798360 /pkgs/test/cue
parentf25d48180af90638001104a61d6d10b22e4ecb28 (diff)
cue: test in tests.cue-validation
Diffstat (limited to 'pkgs/test/cue')
-rw-r--r--pkgs/test/cue/default.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkgs/test/cue/default.nix b/pkgs/test/cue/default.nix
new file mode 100644
index 0000000000000..2cc8bf34bb043
--- /dev/null
+++ b/pkgs/test/cue/default.nix
@@ -0,0 +1,24 @@
+{ writeCueValidator, runCommand, writeText, ... }:
+
+let
+  validator = writeCueValidator
+    (writeText "schema.cue" ''
+      #Def1: {
+        field1: string
+      }
+    '')
+    { document = "#Def1"; };
+in runCommand "cue-validation" {} ''
+  cat > valid.json <<EOF
+  { "field1": "abc" }
+  EOF
+  cat > invalid.json <<EOF
+  { "field2": "abc" }
+  EOF
+  ${validator} valid.json
+  if ${validator} invalid.json; then
+    echo "this example should fail"
+    exit 1
+  fi
+  touch $out
+''