From d2580f4a73d0a1ba37dbe3e9bd134c30329d24b4 Mon Sep 17 00:00:00 2001 From: Vasek - Tom C Date: Fri, 17 Dec 2021 20:29:15 +0100 Subject: [PATCH] Add mkdir task tests Signed-off-by: Vasek - Tom C --- tests/tasks.bats | 19 ++++++++++- tests/tasks/mkdir/cue.mod/module.cue | 1 + tests/tasks/mkdir/cue.mod/pkg/.gitignore | 3 ++ tests/tasks/mkdir/mkdir.cue | 33 ++++++++++++++++++ .../mkdir/mkdir_failure_disable_parents.cue | 34 +++++++++++++++++++ tests/tasks/mkdir/mkdir_parents.cue | 33 ++++++++++++++++++ 6 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/tasks/mkdir/cue.mod/module.cue create mode 100644 tests/tasks/mkdir/cue.mod/pkg/.gitignore create mode 100644 tests/tasks/mkdir/mkdir.cue create mode 100644 tests/tasks/mkdir/mkdir_failure_disable_parents.cue create mode 100644 tests/tasks/mkdir/mkdir_parents.cue diff --git a/tests/tasks.bats b/tests/tasks.bats index 93f74820..a0d6fc8f 100644 --- a/tests/tasks.bats +++ b/tests/tasks.bats @@ -51,7 +51,24 @@ setup() { cd "$TESTDIR"/tasks/copy "$DAGGER" --europa up ./copy_exec.cue "$DAGGER" --europa up ./copy_file.cue - + run "$DAGGER" --europa up ./copy_exec_invalid.cue assert_failure } + + +@test "task: #Mkdir" { + cd "$TESTDIR"/tasks/mkdir + "$DAGGER" --europa up ./mkdir.cue +} + +@test "task: #Mkdir: create parents" { + cd "$TESTDIR"/tasks/mkdir + "$DAGGER" --europa up ./mkdir_parents.cue +} + +@test "task: #Mkdir failure: disable parents creation" { + cd "$TESTDIR"/tasks/mkdir + run "$DAGGER" --europa up ./mkdir_failure_disable_parents.cue + assert_failure +} \ No newline at end of file diff --git a/tests/tasks/mkdir/cue.mod/module.cue b/tests/tasks/mkdir/cue.mod/module.cue new file mode 100644 index 00000000..f8af9cef --- /dev/null +++ b/tests/tasks/mkdir/cue.mod/module.cue @@ -0,0 +1 @@ +module: "" diff --git a/tests/tasks/mkdir/cue.mod/pkg/.gitignore b/tests/tasks/mkdir/cue.mod/pkg/.gitignore new file mode 100644 index 00000000..2d4dc1ae --- /dev/null +++ b/tests/tasks/mkdir/cue.mod/pkg/.gitignore @@ -0,0 +1,3 @@ +# generated by dagger +alpha.dagger.io +dagger.lock diff --git a/tests/tasks/mkdir/mkdir.cue b/tests/tasks/mkdir/mkdir.cue new file mode 100644 index 00000000..886ec29b --- /dev/null +++ b/tests/tasks/mkdir/mkdir.cue @@ -0,0 +1,33 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } + + mkdir: engine.#Mkdir & { + input: image.output + path: "/test" + } + + writeChecker: engine.#WriteFile & { + input: mkdir.output + path: "/test/foo" + contents: "bar" + mode: 700 + } + + readChecker: engine.#ReadFile & { + input: writeChecker.output + path: "/test/foo" + } & { + // assert result + contents: "bar" + } + } +} \ No newline at end of file diff --git a/tests/tasks/mkdir/mkdir_failure_disable_parents.cue b/tests/tasks/mkdir/mkdir_failure_disable_parents.cue new file mode 100644 index 00000000..9cf76775 --- /dev/null +++ b/tests/tasks/mkdir/mkdir_failure_disable_parents.cue @@ -0,0 +1,34 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } + + mkdir: engine.#Mkdir & { + input: image.output + path: "/test/baz" + parents: false + } + + writeChecker: engine.#WriteFile & { + input: mkdir.output + path: "/test/baz/foo" + contents: "bar" + mode: 700 + } + + readChecker: engine.#ReadFile & { + input: writeChecker.output + path: "/test/baz/foo" + } & { + // assert result + contents: "bar" + } + } +} \ No newline at end of file diff --git a/tests/tasks/mkdir/mkdir_parents.cue b/tests/tasks/mkdir/mkdir_parents.cue new file mode 100644 index 00000000..163608ae --- /dev/null +++ b/tests/tasks/mkdir/mkdir_parents.cue @@ -0,0 +1,33 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } + + mkdir: engine.#Mkdir & { + input: image.output + path: "/test/baz" + } + + writeChecker: engine.#WriteFile & { + input: mkdir.output + path: "/test/baz/foo" + contents: "bar" + mode: 700 + } + + readChecker: engine.#ReadFile & { + input: writeChecker.output + path: "/test/baz/foo" + } & { + // assert result + contents: "bar" + } + } +} \ No newline at end of file