summaryrefslogtreecommitdiff
path: root/pkgs/test/cue/default.nix
blob: c5adf662b0ab37029dae0d48d8141807af3a8518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  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
''