Merge pull request #1475 from TomChv/test/docker

Add test on docker.#Run
This commit is contained in:
Andrea Luzzardi 2022-01-24 17:24:32 -08:00 committed by GitHub
commit 3c45dd195b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"
}
}
}