netlify: cleanup tests

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2022-02-09 00:26:12 +00:00
parent 20e1ac9d7f
commit 7502bc876b
3 changed files with 61 additions and 58 deletions

View File

@ -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)"
"""#
}
}
}

View File

@ -4,6 +4,6 @@ setup() {
common_setup common_setup
} }
@test "netlify.#Deploy" { @test "netlify" {
dagger up ./netlify-test.cue dagger up
} }

View File

@ -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)"
"""#
}
}
}
}