Merge pull request #1475 from TomChv/test/docker
Add test on docker.#Run
This commit is contained in:
commit
3c45dd195b
@ -11,3 +11,10 @@ setup() {
|
||||
run dagger up ./multi-nested-build-test.cue
|
||||
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
|
||||
}
|
||||
|
29
pkg/universe.dagger.io/docker/test/run-command-test.cue
Normal file
29
pkg/universe.dagger.io/docker/test/run-command-test.cue
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
23
pkg/universe.dagger.io/docker/test/run-export-file-test.cue
Normal file
23
pkg/universe.dagger.io/docker/test/run-export-file-test.cue
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
pkg/universe.dagger.io/docker/test/run-script-test.cue
Normal file
29
pkg/universe.dagger.io/docker/test/run-script-test.cue
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user