Add test for docker example
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
a79f10a9bb
commit
24aee99ba9
@ -9,6 +9,6 @@ import (
|
||||
source: dagger.#Artifact
|
||||
|
||||
// Container image
|
||||
container: docker.#ImageFromSource & {
|
||||
container: docker.#Build & {
|
||||
"source": source
|
||||
}
|
||||
|
@ -18,3 +18,11 @@ setup() {
|
||||
assert_success
|
||||
assert_output --partial "Todo App"
|
||||
}
|
||||
|
||||
@test "example: docker" {
|
||||
skip_unless_file_exist "$TESTDIR"/examples/docker/Dockerfile
|
||||
|
||||
"$DAGGER" new --plan-dir "$TESTDIR"/../examples/docker/ docker
|
||||
"$DAGGER" input dir source "$TESTDIR"/examples/docker/ -e "docker"
|
||||
"$DAGGER" up -e "docker"
|
||||
}
|
2
tests/examples/docker/Dockerfile
Normal file
2
tests/examples/docker/Dockerfile
Normal file
@ -0,0 +1,2 @@
|
||||
FROM alpine
|
||||
RUN echo test >> /test.txt
|
@ -19,6 +19,11 @@ skip_unless_secrets_available() {
|
||||
sops exec-file "$inputFile" echo > /dev/null 2>&1 || skip "$inputFile cannot be decrypted"
|
||||
}
|
||||
|
||||
skip_unless_file_exist() {
|
||||
local inputFile="$1"
|
||||
test -f "$inputFile" || skip "$inputFile does not exist"
|
||||
}
|
||||
|
||||
skip_unless_local_kube() {
|
||||
if [ -f ~/.kube/config ] && grep -q "user: kind-kind" ~/.kube/config &> /dev/null && grep -q "127.0.0.1" ~/.kube/config &> /dev/null; then
|
||||
echo "Kubernetes available"
|
||||
|
@ -60,6 +60,19 @@ setup() {
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/aws/ecr --input-yaml "$TESTDIR"/stdlib/aws/inputs.yaml
|
||||
}
|
||||
|
||||
@test "stdlib: docker-build" {
|
||||
skip_unless_file_exist "$TESTDIR"/stdlib/docker/build/Dockerfile
|
||||
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/docker/build/ --input-dir source="$TESTDIR"/stdlib/docker/build
|
||||
}
|
||||
|
||||
@test "stdlib: docker-pull" {
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/docker/pull/
|
||||
}
|
||||
|
||||
@test "stdlib: docker-dockerfile" {
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/docker/dockerfile/ --input-dir source="$TESTDIR"/stdlib/docker/dockerfile/testdata
|
||||
}
|
||||
@test "stdlib: terraform" {
|
||||
skip_unless_secrets_available "$TESTDIR"/stdlib/aws/inputs.yaml
|
||||
|
||||
|
2
tests/stdlib/docker/build/Dockerfile
Normal file
2
tests/stdlib/docker/build/Dockerfile
Normal file
@ -0,0 +1,2 @@
|
||||
FROM alpine
|
||||
RUN echo test >> /test.txt
|
31
tests/stdlib/docker/build/build.cue
Normal file
31
tests/stdlib/docker/build/build.cue
Normal file
@ -0,0 +1,31 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/op"
|
||||
"dagger.io/docker"
|
||||
)
|
||||
|
||||
// Build a Docker image from source, using included Dockerfile
|
||||
source: dagger.#Artifact
|
||||
|
||||
TestBuild: {
|
||||
image: docker.#Build & {
|
||||
"source": source
|
||||
}
|
||||
|
||||
verify: #up: [
|
||||
op.#Load & {
|
||||
from: image
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", """
|
||||
grep -q "test" /test.txt
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
34
tests/stdlib/docker/dockerfile/dockerfile.cue
Normal file
34
tests/stdlib/docker/dockerfile/dockerfile.cue
Normal file
@ -0,0 +1,34 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/dagger/op"
|
||||
"dagger.io/docker"
|
||||
)
|
||||
|
||||
source: dagger.#Artifact
|
||||
|
||||
TestImageFromDockerfile: {
|
||||
image: docker.#ImageFromDockerfile & {
|
||||
dockerfile: """
|
||||
FROM alpine
|
||||
COPY test.txt /test.txt
|
||||
"""
|
||||
context: source
|
||||
}
|
||||
|
||||
verify: #up: [
|
||||
op.#Load & {
|
||||
from: image
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", """
|
||||
grep -q "test" /test.txt
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
1
tests/stdlib/docker/dockerfile/testdata/test.txt
vendored
Normal file
1
tests/stdlib/docker/dockerfile/testdata/test.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
test
|
27
tests/stdlib/docker/pull/pull.cue
Normal file
27
tests/stdlib/docker/pull/pull.cue
Normal file
@ -0,0 +1,27 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"dagger.io/dagger/op"
|
||||
"dagger.io/docker"
|
||||
)
|
||||
|
||||
TestImageFromRegistry: {
|
||||
image: docker.#Pull & {
|
||||
from: "index.docker.io/the0only0vasek/alpine-test"
|
||||
}
|
||||
|
||||
verify: #up: [
|
||||
op.#Load & {
|
||||
from: image
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"sh", "-c", """
|
||||
grep -q "test" /test.txt
|
||||
""",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user