From 7502bc876bccac08356d6010f44564c00f6bbbc6 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Wed, 9 Feb 2022 00:26:12 +0000 Subject: [PATCH] netlify: cleanup tests Signed-off-by: Solomon Hykes --- .../netlify/test/netlify-test.cue | 56 ------------------ .../netlify/test/{netlify.bats => test.bats} | 4 +- pkg/universe.dagger.io/netlify/test/test.cue | 59 +++++++++++++++++++ 3 files changed, 61 insertions(+), 58 deletions(-) delete mode 100644 pkg/universe.dagger.io/netlify/test/netlify-test.cue rename pkg/universe.dagger.io/netlify/test/{netlify.bats => test.bats} (51%) create mode 100644 pkg/universe.dagger.io/netlify/test/test.cue diff --git a/pkg/universe.dagger.io/netlify/test/netlify-test.cue b/pkg/universe.dagger.io/netlify/test/netlify-test.cue deleted file mode 100644 index 4de4864d..00000000 --- a/pkg/universe.dagger.io/netlify/test/netlify-test.cue +++ /dev/null @@ -1,56 +0,0 @@ -package yarn - -import ( - "dagger.io/dagger" - "dagger.io/dagger/engine" - - "universe.dagger.io/netlify" - "universe.dagger.io/alpine" - "universe.dagger.io/bash" -) - -dagger.#Plan & { - inputs: secrets: test: command: { - name: "sops" - args: ["-d", "../../test_secrets.yaml"] - } - - actions: { - testSecrets: dagger.#DecodeSecret & { - input: inputs.secrets.test.contents - format: "yaml" - } - - marker: "hello world" - - data: engine.#WriteFile & { - input: engine.#Scratch - path: "index.html" - contents: marker - } - - // Deploy to netlify - deploy: netlify.#Deploy & { - team: "blocklayer" - token: testSecrets.output.netlifyToken.contents - - site: "dagger-test" - contents: data.output - } - - image: alpine.#Build & { - packages: { - bash: {} - curl: {} - } - } - - // Check if the website was deployed - verify: bash.#Run & { - input: image.output - script: contents: #""" - test "$(curl \#(deploy.deployUrl))" = "\#(marker)" - """# - } - } -} diff --git a/pkg/universe.dagger.io/netlify/test/netlify.bats b/pkg/universe.dagger.io/netlify/test/test.bats similarity index 51% rename from pkg/universe.dagger.io/netlify/test/netlify.bats rename to pkg/universe.dagger.io/netlify/test/test.bats index 9f665e9e..29f6d1d1 100644 --- a/pkg/universe.dagger.io/netlify/test/netlify.bats +++ b/pkg/universe.dagger.io/netlify/test/test.bats @@ -4,6 +4,6 @@ setup() { common_setup } -@test "netlify.#Deploy" { - dagger up ./netlify-test.cue +@test "netlify" { + dagger up } diff --git a/pkg/universe.dagger.io/netlify/test/test.cue b/pkg/universe.dagger.io/netlify/test/test.cue new file mode 100644 index 00000000..3a486b1d --- /dev/null +++ b/pkg/universe.dagger.io/netlify/test/test.cue @@ -0,0 +1,59 @@ +package yarn + +import ( + "dagger.io/dagger" + "dagger.io/dagger/engine" + + "universe.dagger.io/netlify" + "universe.dagger.io/alpine" + "universe.dagger.io/bash" +) + +dagger.#Plan & { + inputs: secrets: test: command: { + name: "sops" + args: ["-d", "../../test_secrets.yaml"] + } + + actions: tests: { + // Test: netlify.#Deploy correctly receives API token + receiveToken: { + testSecrets: dagger.#DecodeSecret & { + input: inputs.secrets.test.contents + format: "yaml" + } + + marker: "hello world" + + data: engine.#WriteFile & { + input: engine.#Scratch + path: "index.html" + contents: marker + } + + // Deploy to netlify + deploy: netlify.#Deploy & { + team: "blocklayer" + token: testSecrets.output.netlifyToken.contents + + site: "dagger-test" + contents: data.output + } + + image: alpine.#Build & { + packages: { + bash: {} + curl: {} + } + } + + // Check if the website was deployed + verify: bash.#Run & { + input: image.output + script: contents: #""" + test "$(curl \#(deploy.deployUrl))" = "\#(marker)" + """# + } + } + } +}