Add tests on architecture configuration
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
e9de597654
commit
8a3a3028fb
@ -159,6 +159,28 @@ setup() {
|
||||
"$DAGGER" up
|
||||
}
|
||||
|
||||
@test "core: arch config" {
|
||||
dagger init
|
||||
|
||||
# Test for amd64 architecture
|
||||
dagger_new_with_plan test-amd "$TESTDIR"/core/arch-config "linux/amd64"
|
||||
|
||||
# Set arch expected value
|
||||
"$DAGGER" -e test-amd input text targetArch "x86_64"
|
||||
|
||||
# Up amd
|
||||
"$DAGGER" -e test-amd up
|
||||
|
||||
# Test for amd64 architecture
|
||||
dagger_new_with_plan test-arm "$TESTDIR"/core/arch-config "linux/arm64"
|
||||
|
||||
# Set arch expected value
|
||||
"$DAGGER" -e test-arm input text targetArch "aarch64"
|
||||
|
||||
# Up arm
|
||||
"$DAGGER" -e test-arm up
|
||||
}
|
||||
|
||||
@test "compute: exclude" {
|
||||
"$DAGGER" up --project "$TESTDIR"/compute/exclude
|
||||
}
|
||||
|
58
tests/core/arch-config/arch-config.cue
Normal file
58
tests/core/arch-config/arch-config.cue
Normal file
@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/dagger/op"
|
||||
"alpha.dagger.io/dagger"
|
||||
)
|
||||
|
||||
targetArch: dagger.#Input & {string}
|
||||
|
||||
TestFetch: #up: [
|
||||
op.#FetchContainer & {
|
||||
ref: "docker.io/alpine"
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
args: ["/bin/sh", "-c", "echo $(uname -a) >> /arch.txt"]
|
||||
always: true
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
args: ["/bin/sh", "-c", """
|
||||
cat /arch.txt | grep "$TARGET_ARCH"
|
||||
"""]
|
||||
env: TARGET_ARCH: targetArch
|
||||
},
|
||||
]
|
||||
|
||||
TestBuild: #up: [
|
||||
op.#DockerBuild & {
|
||||
dockerfile: """
|
||||
FROM alpine
|
||||
|
||||
RUN echo $(uname -a) > /arch.txt
|
||||
"""
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
args: ["/bin/sh", "-c", """
|
||||
cat /arch.txt | grep "$TARGET_ARCH"
|
||||
"""]
|
||||
env: TARGET_ARCH: targetArch
|
||||
},
|
||||
]
|
||||
|
||||
TestLoad: #up: [
|
||||
op.#Load & {
|
||||
from: TestBuild
|
||||
},
|
||||
|
||||
// Compare arch
|
||||
op.#Exec & {
|
||||
args: ["/bin/sh", "-c", "diff /build/arch.txt /fetch/arch.txt"]
|
||||
mount: {
|
||||
"/build": from: TestBuild
|
||||
"/fetch": from: TestFetch
|
||||
}
|
||||
},
|
||||
]
|
@ -20,10 +20,19 @@ common_setup() {
|
||||
dagger_new_with_plan() {
|
||||
local name="$1"
|
||||
local sourcePlan="$2"
|
||||
local arch="$3"
|
||||
|
||||
cp -a "$sourcePlan"/* "$DAGGER_PROJECT"
|
||||
|
||||
"$DAGGER" new "$name"
|
||||
local opts=""
|
||||
if [ -n "$arch" ];
|
||||
then
|
||||
opts="-a $arch"
|
||||
fi
|
||||
|
||||
# Need word splitting to take in account "-a" and "$arch"
|
||||
# shellcheck disable=SC2086
|
||||
"$DAGGER" new "$name" ${opts}
|
||||
}
|
||||
|
||||
dagger_new_with_env() {
|
||||
|
Reference in New Issue
Block a user