Add test on docker.#Run

Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
This commit is contained in:
Vasek - Tom C 2022-01-21 17:02:12 +01:00
parent a6330f8167
commit 4ab852347b
No known key found for this signature in database
GPG Key ID: 175D82E572427960
5 changed files with 126 additions and 0 deletions

View File

@ -11,3 +11,10 @@ setup() {
run dagger up ./multi-nested-build-test.cue run dagger up ./multi-nested-build-test.cue
assert_failure assert_failure
} }
@test "docker.#Run" {
dagger up ./run-command-test.cue
dagger up ./run-script-test.cue
dagger up ./run-export-file-test.cue
dagger up ./run-export-directory-test.cue
}

View File

@ -0,0 +1,29 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
dagger.#Plan & {
actions: {
image: alpine.#Build
run: docker.#Run & {
"image": image.output
cmd: {
name: "/bin/sh"
args: ["-c", "echo -n hello world >> /output.txt"]
}
}
verify: engine.#ReadFile & {
input: run.output.rootfs
path: "/output.txt"
} & {
contents: "hello world"
}
}
}

View File

@ -0,0 +1,38 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
dagger.#Plan & {
actions: {
image: alpine.#Build
run: docker.#Run & {
"image": image.output
script: #"""
mkdir -p test
echo -n hello world >> /test/output.txt
"""#
export: {
directories: "/test": _
files: "/test/output.txt": _ & {
contents: "hello world"
}
}
} & {
completed: true
success: true
}
verify: engine.#ReadFile & {
input: run.export.directories."/test".contents
path: "/output.txt"
} & {
contents: run.export.files."/test/output.txt".contents
}
}
}

View File

@ -0,0 +1,23 @@
package test
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
dagger.#Plan & {
actions: {
image: alpine.#Build
run: docker.#Run & {
"image": image.output
script: #"""
echo -n hello world >> /output.txt
"""#
export: files: "/output.txt": _ & {
contents: "hello world"
}
}
}
}

View File

@ -0,0 +1,29 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
dagger.#Plan & {
actions: {
image: alpine.#Build
run: docker.#Run & {
"image": image.output
script: #"""
echo -n $TEST_MESSAGE >> /output.txt
"""#
env: TEST_MESSAGE: "hello world"
}
verify: engine.#ReadFile & {
input: run.output.rootfs
path: "/output.txt"
} & {
contents: "hello world"
}
}
}