Add test for docker example

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-05-06 22:27:45 +02:00
parent a79f10a9bb
commit 24aee99ba9
10 changed files with 124 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
FROM alpine
RUN echo test >> /test.txt

View 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
""",
]
},
]
}

View 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
""",
]
},
]
}

View File

@@ -0,0 +1 @@
test

View 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
""",
]
},
]
}