about summary refs log tree commit diff
path: root/pkgs/test/cue/default.nix
blob: 2cc8bf34bb043d60fa561498131234e62f02067c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
''