Add do tests

Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
Joel Longtine
2022-03-07 16:53:50 -07:00
parent 2a6962ddc8
commit 5afaedc9ab
4 changed files with 196 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
package main
import (
"dagger.io/dagger"
"universe.dagger.io/alpine"
"universe.dagger.io/bash"
)
dagger.#Plan & {
// This is acting weird...
// I don't understand why `cue/flow` thinks that outputs.files.test has a dependency
// on actions.fromAndrea.a.export._files."/output.txt"._read
// It _does_ fail correctly, FWIW, when it reaches this code.
// TASK: outputs.files.test
// DEPENDENCIES:
// actions.fromAndrea.a.export._files."/output.txt"._read
// actions.image._dag."1"._exec
// actions.image._dag."0"._op
outputs: files: test: {
dest: "./test_do"
contents: actions.test1.one.export.files["/output.txt"]
}
actions: {
image: alpine.#Build & {
packages: bash: {}
}
abcAction: {
a: bash.#Run & {
input: image.output
script: contents: "echo -n 'from andrea with love' > /output.txt"
export: files: "/output.txt": string
}
b: {
x: bash.#Run & {
input: image.output
script: contents: "echo -n false > /output.txt"
export: files: "/output.txt": string
}
if x.export.files["/output.txt"] == "false" {
y: bash.#Run & {
input: a.output
script: contents: "echo -n hello from y"
export: files: "/output.txt": "from andrea with love"
}
}
}
}
notMe: bash.#Run & {
input: image.output
script: contents: "false"
}
}
}

View File

@@ -0,0 +1,61 @@
package main
import (
"dagger.io/dagger"
"universe.dagger.io/alpine"
"universe.dagger.io/bash"
)
dagger.#Plan & {
outputs: files: test: {
dest: "./test_do"
contents: actions.test.one.export.files["/output.txt"]
}
outputs: files: dependent: {
dest: "./dependent_do"
contents: actions.dependent.one.export.files["/output.txt"]
}
actions: {
image: alpine.#Build & {
packages: bash: {}
}
test: {
one: bash.#Run & {
input: image.output
script: contents: "echo Hello World! > /output.txt"
export: files: "/output.txt": string
}
two: bash.#Run & {
input: image.output
script: contents: "true"
}
three: bash.#Run & {
input: image.output
script: contents: "cat /one/output.txt"
mounts: output: {
contents: one.export.rootfs
dest: "/one"
}
}
}
dependent: {
one: bash.#Run & {
input: test.one.output
script: contents: "cat /output.txt"
export: files: "/output.txt": string
}
}
notMe: bash.#Run & {
input: image.output
script: contents: "false"
}
}
}

View File

@@ -0,0 +1,49 @@
package main
import (
"dagger.io/dagger"
"universe.dagger.io/alpine"
"universe.dagger.io/bash"
)
dagger.#Plan & {
outputs: files: andrea: {
dest: "./andrea_do"
contents: actions.test.b.y.export.files["/output.txt"]
}
actions: {
image: alpine.#Build & {
packages: bash: {}
}
test: {
a: bash.#Run & {
input: image.output
script: contents: "echo -n 'from andrea with love' > /output.txt"
export: files: "/output.txt": string
}
b: {
x: bash.#Run & {
input: image.output
script: contents: "echo -n testing > /output.txt"
export: files: "/output.txt": string
}
// This fails. Building the Actions lookup table breaks
if x.export.files["/output.txt"] == "testing" {
y: bash.#Run & {
input: a.output
script: contents: "echo -n hello from y"
export: files: "/output.txt": string
}
}
}
}
// notMe: bash.#Run & {
// input: image.output
// script: contents: "false"
// }
}
}