From 01414f80c97826539d5637d37e733f827906059a Mon Sep 17 00:00:00 2001 From: Vasek - Tom C Date: Thu, 23 Dec 2021 15:28:36 +0100 Subject: [PATCH] Add tests on plan platform configuration Signed-off-by: Vasek - Tom C --- tests/plan.bats | 14 ++++++++ ...nfig_platform_failure_invalid_platform.cue | 32 +++++++++++++++++++ .../platform/config_platform_linux_amd64.cue | 32 +++++++++++++++++++ .../platform/config_platform_linux_arm64.cue | 32 +++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 tests/plan/platform/config_platform_failure_invalid_platform.cue create mode 100644 tests/plan/platform/config_platform_linux_amd64.cue create mode 100644 tests/plan/platform/config_platform_linux_arm64.cue diff --git a/tests/plan.bats b/tests/plan.bats index c5a92ce1..ef320499 100644 --- a/tests/plan.bats +++ b/tests/plan.bats @@ -77,3 +77,17 @@ setup() { "$DAGGER" --europa up ./outputs.cue assert [ -f "./out/test" ] } + +@test "plan/platform" { + cd "$TESTDIR" + + # Run with amd64 platform + run "$DAGGER" --europa up ./plan/platform/config_platform_linux_amd64.cue + + # Run with arm64 platform + run "$DAGGER" --europa up ./plan/platform/config_platform_linux_arm64.cue + + # Run with invalid platform + run "$DAGGER" --europa up ./plan/platform/config_platform_failure_invalid_platform.cue + assert_failure +} \ No newline at end of file diff --git a/tests/plan/platform/config_platform_failure_invalid_platform.cue b/tests/plan/platform/config_platform_failure_invalid_platform.cue new file mode 100644 index 00000000..457a3cf6 --- /dev/null +++ b/tests/plan/platform/config_platform_failure_invalid_platform.cue @@ -0,0 +1,32 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + platform: "linux/unknown" + + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0" + } + + writeArch: engine.#Exec & { + input: image.output + always: true + args: [ + "sh", "-c", #""" + echo -n $(uname -m) >> /arch.txt + """#, + ] + } + + verify: engine.#ReadFile & { + input: writeArch.output + path: "/arch.txt" + } & { + contents: "s390x" + } + } +} diff --git a/tests/plan/platform/config_platform_linux_amd64.cue b/tests/plan/platform/config_platform_linux_amd64.cue new file mode 100644 index 00000000..e1902bb3 --- /dev/null +++ b/tests/plan/platform/config_platform_linux_amd64.cue @@ -0,0 +1,32 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + platform: "linux/amd64" + + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0" + } + + writeArch: engine.#Exec & { + input: image.output + always: true + args: [ + "sh", "-c", #""" + echo -n $(uname -m) >> /arch.txt + """#, + ] + } + + verify: engine.#ReadFile & { + input: writeArch.output + path: "/arch.txt" + } & { + contents: "x86_64" + } + } +} diff --git a/tests/plan/platform/config_platform_linux_arm64.cue b/tests/plan/platform/config_platform_linux_arm64.cue new file mode 100644 index 00000000..eb497405 --- /dev/null +++ b/tests/plan/platform/config_platform_linux_arm64.cue @@ -0,0 +1,32 @@ +package main + +import ( + "alpha.dagger.io/europa/dagger/engine" +) + +engine.#Plan & { + platform: "linux/arm64" + + actions: { + image: engine.#Pull & { + source: "alpine:3.15.0" + } + + writeArch: engine.#Exec & { + input: image.output + always: true + args: [ + "sh", "-c", #""" + echo -n $(uname -m) >> /arch.txt + """#, + ] + } + + verify: engine.#ReadFile & { + input: writeArch.output + path: "/arch.txt" + } & { + contents: "aarch64" + } + } +}