This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/tests/helpers.bash
Andrea Luzzardi c7c8c5fa8d tests: fix integration tests
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2021-05-25 15:17:32 -07:00

38 lines
1.1 KiB
Bash

common_setup() {
load 'node_modules/bats-support/load'
load 'node_modules/bats-assert/load'
TESTDIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
DAGGER="${DAGGER_BINARY:-$TESTDIR/../cmd/dagger/dagger}"
export DAGGER
DAGGER_LOG_FORMAT="pretty"
export DAGGER_LOG_FORMAT
DAGGER_WORKSPACE="$(mktemp -d -t dagger-workspace-XXXXXX)"
export DAGGER_WORKSPACE
}
dagger_new_with_plan() {
local name="$1"
local sourcePlan="$2"
local targetPlan="$DAGGER_WORKSPACE"/.dagger/env/"$name"/plan
"$DAGGER" new "$name"
rmdir "$targetPlan"
ln -s "$sourcePlan" "$targetPlan"
}
skip_unless_secrets_available() {
local inputFile="$1"
sops exec-file "$inputFile" echo > /dev/null 2>&1 || skip "$inputFile cannot be decrypted"
}
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"
else
skip "local kubernetes cluster not available"
fi
}