From 70c0f362eaf80247b5728a7e87a57ff2e29cef19 Mon Sep 17 00:00:00 2001 From: Joel Longtine Date: Tue, 22 Feb 2022 13:21:32 -0700 Subject: [PATCH] Update plan tests to use Europa constructs Signed-off-by: Joel Longtine --- tests/plan.bats | 22 ++++++++---------- tests/plan/hello-europa/main.cue | 20 ++++++++++++---- tests/plan/proxy/incomplete_service.cue | 31 ++++++++++++++----------- tests/plan/proxy/incomplete_unix.cue | 31 ++++++++++++++----------- tests/plan/proxy/invalid_schema.cue | 31 ++++++++++++++----------- tests/plan/proxy/invalid_value.cue | 31 ++++++++++++++----------- tests/plan/proxy/unix.cue | 31 ++++++++++++++----------- 7 files changed, 115 insertions(+), 82 deletions(-) diff --git a/tests/plan.bats b/tests/plan.bats index 6c60fca7..2dde8f75 100644 --- a/tests/plan.bats +++ b/tests/plan.bats @@ -16,12 +16,11 @@ setup() { assert_failure } -# TODO/FIXME: this test is broken, it's not asserting that the proxy is not running -# @test "plan/proxy invalid value" { -# cd "$TESTDIR" -# run "$DAGGER" up ./plan/proxy/invalid_value.cue -# assert_failure -# } +@test "plan/proxy invalid value" { + cd "$TESTDIR" + run "$DAGGER" up ./plan/proxy/invalid_value.cue + assert_failure +} @test "plan/proxy incomplete unix" { cd "$TESTDIR" @@ -29,12 +28,11 @@ setup() { assert_failure } -# TODO/FIXME: this test is broken, it's not asserting that the proxy is not running -# @test "plan/proxy incomplete service" { -# cd "$TESTDIR" -# run "$DAGGER" up ./plan/proxy/incomplete_service.cue -# assert_output --partial "pipeline was partially executed because of missing inputs" -# } +@test "plan/proxy incomplete service" { + cd "$TESTDIR" + run "$DAGGER" up ./plan/proxy/incomplete_service.cue + assert_output --partial 'mount "docker" is not concrete' +} @test "plan/proxy unix" { cd "$TESTDIR" diff --git a/tests/plan/hello-europa/main.cue b/tests/plan/hello-europa/main.cue index 62ea2ea4..0ae85271 100644 --- a/tests/plan/hello-europa/main.cue +++ b/tests/plan/hello-europa/main.cue @@ -7,11 +7,21 @@ import ( dagger.#Plan & { actions: { - // TODO/FIXME: Use Europa constructs for this - // sayHello: os.#Container & { - // command: "echo Hello Europa! > /out.txt" - // } + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // verify: "Hello Europa!\n" & (os.#File & {from: sayHello, path: "/out.txt"}).contents + exec: dagger.#Exec & { + input: image.output + args: ["sh", "-c", "echo -n Hello Europa > /out.txt"] + } + + verify: dagger.#ReadFile & { + input: exec.output + path: "/out.txt" + } & { + // assert result + contents: "Hello Europa" + } } } diff --git a/tests/plan/proxy/incomplete_service.cue b/tests/plan/proxy/incomplete_service.cue index 70b9c037..8b5d683b 100644 --- a/tests/plan/proxy/incomplete_service.cue +++ b/tests/plan/proxy/incomplete_service.cue @@ -10,18 +10,23 @@ dagger.#Plan & { // should fail due to incomplete service proxy: dockerSocket: {} - // TODO/FIXME: Use Europa constructs for this - // actions: test: #up: [ - // op.#Load & { - // from: alpine.#Image & { - // package: "docker-cli": true - // } - // }, + actions: { + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // op.#Exec & { - // always: true - // mount: "/var/run/docker.sock": stream: proxy.dockerSocket.service - // args: ["docker", "info"] - // }, - // ] + imageWithDocker: dagger.#Exec & { + input: image.output + args: ["apk", "add", "--no-cache", "docker-cli"] + } + + verify: dagger.#Exec & { + input: imageWithDocker.output + mounts: docker: { + dest: "/var/run/docker.sock" + contents: proxy.dockerSocket.service + } + args: ["docker", "info"] + } + } } diff --git a/tests/plan/proxy/incomplete_unix.cue b/tests/plan/proxy/incomplete_unix.cue index 6bd26f4c..cf7fd1ea 100644 --- a/tests/plan/proxy/incomplete_unix.cue +++ b/tests/plan/proxy/incomplete_unix.cue @@ -10,18 +10,23 @@ dagger.#Plan & { // should fail because incomplete value proxy: dockerSocket: unix: string - // TODO/FIXME: Use Europa constructs for this - // actions: test: #up: [ - // op.#Load & { - // from: alpine.#Image & { - // package: "docker-cli": true - // } - // }, + actions: { + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // op.#Exec & { - // always: true - // mount: "/var/run/docker.sock": stream: proxy.dockerSocket.service - // args: ["docker", "info"] - // }, - // ] + imageWithDocker: dagger.#Exec & { + input: image.output + args: ["apk", "add", "--no-cache", "docker-cli"] + } + + verify: dagger.#Exec & { + input: imageWithDocker.output + mounts: docker: { + dest: "/var/run/docker.sock" + contents: proxy.dockerSocket.service + } + args: ["docker", "info"] + } + } } diff --git a/tests/plan/proxy/invalid_schema.cue b/tests/plan/proxy/invalid_schema.cue index b49096c3..c1756b8c 100644 --- a/tests/plan/proxy/invalid_schema.cue +++ b/tests/plan/proxy/invalid_schema.cue @@ -10,18 +10,23 @@ dagger.#Plan & { // should fail because of misspelled key proxy: dockerSocket: unx: "/var/run/docker.sock" - // TODO/FIXME: Use Europa constructs for this - // actions: test: #up: [ - // op.#Load & { - // from: alpine.#Image & { - // package: "docker-cli": true - // } - // }, + actions: { + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // op.#Exec & { - // always: true - // mount: "/var/run/docker.sock": stream: proxy.dockerSocket.service - // args: ["docker", "info"] - // }, - // ] + imageWithDocker: dagger.#Exec & { + input: image.output + args: ["apk", "add", "--no-cache", "docker-cli"] + } + + verify: dagger.#Exec & { + input: imageWithDocker.output + mounts: docker: { + dest: "/var/run/docker.sock" + contents: proxy.dockerSocket.service + } + args: ["docker", "info"] + } + } } diff --git a/tests/plan/proxy/invalid_value.cue b/tests/plan/proxy/invalid_value.cue index f6897084..5a4dc253 100644 --- a/tests/plan/proxy/invalid_value.cue +++ b/tests/plan/proxy/invalid_value.cue @@ -10,18 +10,23 @@ dagger.#Plan & { // should fail because of misspelled value proxy: dockerSocket: unix: "/var/run/docker.soc" - // TODO/FIXME: Use Europa constructs for this - // actions: test: #up: [ - // op.#Load & { - // from: alpine.#Image & { - // package: "docker-cli": true - // } - // }, + actions: { + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // op.#Exec & { - // always: true - // mount: "/var/run/docker.sock": stream: proxy.dockerSocket.service - // args: ["docker", "info"] - // }, - // ] + imageWithDocker: dagger.#Exec & { + input: image.output + args: ["apk", "add", "--no-cache", "docker-cli"] + } + + verify: dagger.#Exec & { + input: imageWithDocker.output + mounts: docker: { + dest: "/var/run/docker.sock" + contents: proxy.dockerSocket.service + } + args: ["docker", "info"] + } + } } diff --git a/tests/plan/proxy/unix.cue b/tests/plan/proxy/unix.cue index 0f69796a..47a40c2d 100644 --- a/tests/plan/proxy/unix.cue +++ b/tests/plan/proxy/unix.cue @@ -10,18 +10,23 @@ dagger.#Plan & { // should succeed proxy: dockerSocket: unix: "/var/run/docker.sock" - // TODO/FIXME: Use Europa constructs for this - // actions: test: #up: [ - // op.#Load & { - // from: alpine.#Image & { - // package: "docker-cli": true - // } - // }, + actions: { + image: dagger.#Pull & { + source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" + } - // op.#Exec & { - // always: true - // mount: "/var/run/docker.sock": stream: proxy.dockerSocket.service - // args: ["docker", "info"] - // }, - // ] + imageWithDocker: dagger.#Exec & { + input: image.output + args: ["apk", "add", "--no-cache", "docker-cli"] + } + + verify: dagger.#Exec & { + input: imageWithDocker.output + mounts: docker: { + dest: "/var/run/docker.sock" + contents: proxy.dockerSocket.service + } + args: ["docker", "info"] + } + } }