Use sandbox in tests
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
2e9a0d6509
commit
9c20c45453
@ -39,7 +39,7 @@ TestHelmRepoChart: {
|
||||
seed: "repo"
|
||||
}
|
||||
|
||||
// Deploy chart
|
||||
// Deploy remote chart
|
||||
deploy: helm.#Chart & {
|
||||
name: "dagger-test-repository-\(suffix.out)"
|
||||
namespace: "dagger-test"
|
||||
|
@ -39,12 +39,24 @@ dagger() {
|
||||
# copy_to_sandbox myenv
|
||||
# dagger input secret -w "$DAGGER_SANDBOX" -e myenv "temporary change"
|
||||
# dagger up -w "$DAGGER_SANDBOX" -e myenv
|
||||
#
|
||||
# To use testdata directory in tests, add the package name as second flag
|
||||
# Usage:
|
||||
# copy_to_sandbox myenv mypackage
|
||||
copy_to_sandbox() {
|
||||
local name="$1"
|
||||
local source="$DAGGER_WORKSPACE"/.dagger/env/"$name"
|
||||
local target="$DAGGER_SANDBOX"/.dagger/env/"$name"
|
||||
|
||||
cp -a "$source" "$target"
|
||||
|
||||
if [ -d "$2" ]; then
|
||||
local package="$2"
|
||||
local source_package="$DAGGER_WORKSPACE"/"$package"
|
||||
local target_package="$DAGGER_SANDBOX"/
|
||||
|
||||
cp -a "$source_package" "$target_package"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if there is a local kubernetes cluster.
|
||||
|
@ -64,13 +64,16 @@ setup() {
|
||||
@test "kubernetes: deployment" {
|
||||
skip_unless_local_kube
|
||||
|
||||
# Set kubeconfig
|
||||
dagger -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
|
||||
# Copy deployment to sandbox
|
||||
copy_to_sandbox kubernetes-deployment
|
||||
|
||||
dagger -e kubernetes-deployment up
|
||||
# Set kubeconfig
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config
|
||||
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment up
|
||||
|
||||
# Unset kubeconfig
|
||||
dagger -e kubernetes-deployment input unset TestKubeconfig
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig
|
||||
}
|
||||
|
||||
@test "kubernetes: kustomize" {
|
||||
@ -80,13 +83,16 @@ setup() {
|
||||
@test "kubernetes: helm" {
|
||||
skip_unless_local_kube
|
||||
|
||||
# Set kubeconfig
|
||||
dagger -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
|
||||
# Copy deployment to sandbox
|
||||
copy_to_sandbox kubernetes-helm kubernetes
|
||||
|
||||
dagger -e kubernetes-helm up
|
||||
# Set kubeconfig
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config
|
||||
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm up
|
||||
|
||||
# Unset kubeconfig
|
||||
dagger -e kubernetes-helm input unset TestKubeconfig
|
||||
dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig
|
||||
}
|
||||
|
||||
@test "google cloud: gcr" {
|
||||
@ -102,23 +108,26 @@ setup() {
|
||||
run dagger -e terraform up
|
||||
assert_failure
|
||||
|
||||
# Copy deployment to sandbox
|
||||
copy_to_sandbox terraform terraform
|
||||
|
||||
# Add the var and try again
|
||||
run dagger -e terraform input text TestTerraform.apply.tfvars.input "42"
|
||||
run dagger -e terraform up
|
||||
run dagger -w "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42"
|
||||
run dagger -w "$DAGGER_SANDBOX" -e terraform up
|
||||
assert_success
|
||||
|
||||
# ensure the tfvar was passed correctly
|
||||
run dagger query -e terraform TestTerraform.apply.output.input.value -f text
|
||||
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text
|
||||
assert_success
|
||||
assert_output "42"
|
||||
|
||||
# ensure the random value is always the same
|
||||
# this proves we're effectively using the s3 backend
|
||||
run dagger query -e terraform TestTerraform.apply.output.random.value -f json
|
||||
run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json
|
||||
assert_success
|
||||
assert_output "36"
|
||||
|
||||
# Unset input
|
||||
run dagger -e terraform input unset TestTerraform.apply.tfvars.input
|
||||
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
|
||||
assert_success
|
||||
}
|
Reference in New Issue
Block a user