Merge pull request #1524 from TomChv/test/docker-build

Add tests on `docker.#Build` definition
This commit is contained in:
Andrea Luzzardi 2022-01-28 13:33:17 -08:00 committed by GitHub
commit 49e7f2860f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
// This test verify that we can correctly build an image
// using docker.#Build with multiple steps executed during
// the building process
dagger.#Plan & {
actions: {
image: docker.#Build & {
steps: [
alpine.#Build,
docker.#Run & {
script: """
echo -n hello > /bar.txt
"""
},
docker.#Run & {
script: """
echo -n $(cat /bar.txt) world > /foo.txt
"""
},
docker.#Run & {
script: """
echo -n $(cat /foo.txt) >> /test.txt
"""
},
]
}
verify: engine.#ReadFile & {
input: image.output.rootfs
path: "/test.txt"
} & {
contents: "hello world"
}
}
}

View File

@ -0,0 +1,35 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/alpine"
)
// This test verify that we can correctly build a simplistic image
// using docker.#Build
dagger.#Plan & {
#testValue: "hello world"
actions: {
image: docker.#Build & {
steps: [
alpine.#Build,
docker.#Run & {
script: """
echo -n $TEST >> /test.txt
"""
env: TEST: #testValue
},
]
}
verify: engine.#ReadFile & {
input: image.output.rootfs
path: "/test.txt"
} & {
contents: #testValue
}
}
}

View File

@ -5,6 +5,9 @@ setup() {
}
@test "docker.#Build" {
dagger up ./build-simple.cue
dagger up ./build-multi-steps.cue
dagger up ./nested-build-test.cue
# FIXME: this is currently broken