diff --git a/examples/tests/export/bool/main.cue b/examples/tests/export/bool/main.cue new file mode 100644 index 00000000..6145ed22 --- /dev/null +++ b/examples/tests/export/bool/main.cue @@ -0,0 +1,29 @@ +package testing + +test: { + bool + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + printf "true" > /tmp/out + """ + ] + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "bool" + }, + ] + } +} + diff --git a/examples/tests/export/invalid/format/main.cue b/examples/tests/export/invalid/format/main.cue new file mode 100644 index 00000000..368561cf --- /dev/null +++ b/examples/tests/export/invalid/format/main.cue @@ -0,0 +1,29 @@ +package testing + +teststring: { + string + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + echo something > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "lalalalal" + }, + ] + } +} diff --git a/examples/tests/export/invalid/path/main.cue b/examples/tests/export/invalid/path/main.cue new file mode 100644 index 00000000..0a742175 --- /dev/null +++ b/examples/tests/export/invalid/path/main.cue @@ -0,0 +1,20 @@ +package testing + +teststring: { + string + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "export" + // Source path in the container + source: "/tmp/lalala" + format: "string" + }, + ] + } +} diff --git a/examples/tests/export/invalid/validation/main.cue b/examples/tests/export/invalid/validation/main.cue new file mode 100644 index 00000000..c0d33b3a --- /dev/null +++ b/examples/tests/export/invalid/validation/main.cue @@ -0,0 +1,30 @@ +package testing + +test: { + string + =~ "^NAAAA.+" + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + printf something > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "string" + }, + ] + } +} diff --git a/examples/tests/export/json/main.cue b/examples/tests/export/json/main.cue new file mode 100644 index 00000000..a68b024e --- /dev/null +++ b/examples/tests/export/json/main.cue @@ -0,0 +1,27 @@ +package testing + +test: { + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + echo '{"something": "something"}' > /tmp/out + """ + ] + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "json" + }, + ] + } +} diff --git a/examples/tests/export/number/main.cue b/examples/tests/export/number/main.cue new file mode 100644 index 00000000..a6e85b88 --- /dev/null +++ b/examples/tests/export/number/main.cue @@ -0,0 +1,29 @@ +package testing + +test: { + number + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + echo -123.5 > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "number" + }, + ] + } +} diff --git a/examples/tests/export/string/main.cue b/examples/tests/export/string/main.cue new file mode 100644 index 00000000..4494a8a2 --- /dev/null +++ b/examples/tests/export/string/main.cue @@ -0,0 +1,29 @@ +package testing + +test: { + string + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + printf something > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "string" + }, + ] + } +} diff --git a/examples/tests/export/withvalidation/main.cue b/examples/tests/export/withvalidation/main.cue new file mode 100644 index 00000000..1a9ad6a0 --- /dev/null +++ b/examples/tests/export/withvalidation/main.cue @@ -0,0 +1,30 @@ +package testing + +test: { + string + =~ "^some.+" + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + printf something > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "string" + }, + ] + } +} diff --git a/examples/tests/export/yaml/main.cue b/examples/tests/export/yaml/main.cue new file mode 100644 index 00000000..8b0e16f3 --- /dev/null +++ b/examples/tests/export/yaml/main.cue @@ -0,0 +1,29 @@ +package testing + +test: { + + #dagger: { + compute: [ + { + do: "fetch-container" + ref: "alpine" + }, + { + do: "exec" + args: ["sh", "-c", """ + echo "--- # Shopping list + [milk, pumpkin pie, eggs, juice]" > /tmp/out + """ + ] + // XXX Blocked by https://github.com/blocklayerhq/dagger/issues/19 + dir: "/" + }, + { + do: "export" + // Source path in the container + source: "/tmp/out" + format: "yaml" + }, + ] + } +} diff --git a/examples/tests/test.sh b/examples/tests/test.sh index 55b7f278..4e1fb474 100755 --- a/examples/tests/test.sh +++ b/examples/tests/test.sh @@ -91,6 +91,35 @@ test::exec(){ # "$dagger" compute "$d"/exec/dir/exist } +test::export(){ + # XXX https://github.com/blocklayerhq/dagger/issues/36 + #test::one "Export: number" --exit=0 --stdout='{"test": -123.5}' \ + # "$dagger" compute "$d"/export/number + #test::one "Export: yaml" --exit=0 --stdout='XXXXXX' \ + # "$dagger" compute "$d"/export/yaml + # XXX https://github.com/blocklayerhq/dagger/issues/35 + #test::one "Export: bool" --exit=0 --stdout='{"test": false}' \ + # "$dagger" compute "$d"/export/bool + + test::one "Export: json" --exit=0 --stdout='{"test":{"something":"something"}}' \ + "$dagger" compute "$d"/export/json + + test::one "Export: string" --exit=0 --stdout='{"test":"something"}' \ + "$dagger" compute "$d"/export/string + + test::one "Export: string with additional constraint success" --exit=0 --stdout='{"test":"something"}' \ + "$dagger" compute "$d"/export/withvalidation + + test::one "Export: does not pass additional validation" --exit=1 --stdout= \ + "$dagger" compute "$d"/export/invalid/validation + + test::one "Export: invalid format" --exit=1 --stdout= \ + "$dagger" compute "$d"/export/invalid/format + + test::one "Export: invalid path" --exit=1 --stdout= \ + "$dagger" compute "$d"/export/invalid/path +} + test::all(){ local dagger="$1" @@ -98,6 +127,7 @@ test::all(){ test::fetchcontainer "$dagger" test::fetchgit "$dagger" test::exec "$dagger" + test::export "$dagger" # TODO: exec mounts # TODO: copy