Merge pull request #1524 from TomChv/test/docker-build
Add tests on `docker.#Build` definition
This commit is contained in:
commit
49e7f2860f
43
pkg/universe.dagger.io/docker/test/build-multi-steps.cue
Normal file
43
pkg/universe.dagger.io/docker/test/build-multi-steps.cue
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
35
pkg/universe.dagger.io/docker/test/build-simple.cue
Normal file
35
pkg/universe.dagger.io/docker/test/build-simple.cue
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Reference in New Issue
Block a user