test: moar integration tests [ci skip]
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
42
tests/integration/helpers/app.bash
Normal file
42
tests/integration/helpers/app.bash
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_new_app() {
|
||||
run $ABRA app new "$TEST_RECIPE" \
|
||||
--no-input \
|
||||
--server "$TEST_SERVER" \
|
||||
--domain "$TEST_APP_DOMAIN" \
|
||||
--secrets
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||
}
|
||||
|
||||
_deploy_app() {
|
||||
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app ls --server "$TEST_SERVER" --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial 'deployed'
|
||||
}
|
||||
|
||||
_undeploy_app() {
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
|
||||
assert_success
|
||||
|
||||
run $ABRA app ls --server "$TEST_SERVER" --status
|
||||
assert_success
|
||||
assert_output --partial "$TEST_APP_DOMAIN"
|
||||
assert_output --partial 'unknown'
|
||||
}
|
||||
|
||||
_rm_app() {
|
||||
# NOTE(d1): not asserting outcomes on teardown here since some might fail
|
||||
# depending on what the test created. all commands run through anyway
|
||||
if [[ -f "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" ]]; then
|
||||
run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app secret remove "$TEST_APP_DOMAIN" --all --no-input
|
||||
run $ABRA app volume remove "$TEST_APP_DOMAIN" --no-input
|
||||
run $ABRA app remove "$TEST_APP_DOMAIN" --no-input
|
||||
fi
|
||||
}
|
19
tests/integration/helpers/common.bash
Normal file
19
tests/integration/helpers/common.bash
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_common_setup() {
|
||||
load '/usr/lib/bats/bats-support/load'
|
||||
load '/usr/lib/bats/bats-assert/load'
|
||||
load '/usr/lib/bats/bats-file/load'
|
||||
|
||||
load "$PWD/tests/integration/helpers/app"
|
||||
load "$PWD/tests/integration/helpers/git"
|
||||
load "$PWD/tests/integration/helpers/recipe"
|
||||
load "$PWD/tests/integration/helpers/server"
|
||||
|
||||
export ABRA="$PWD/abra"
|
||||
export KADABRA="$PWD/kadabra"
|
||||
|
||||
export TEST_APP_NAME="$(basename "${BATS_TEST_FILENAME//./_}")"
|
||||
export TEST_APP_DOMAIN="$TEST_APP_NAME.$TEST_SERVER"
|
||||
export TEST_RECIPE="abra-integration-test-recipe"
|
||||
}
|
11
tests/integration/helpers/git.bash
Normal file
11
tests/integration/helpers/git.bash
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_checkout_recipe() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo 'forgot to pass argument to function?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$1" checkout .
|
||||
assert_success
|
||||
}
|
16
tests/integration/helpers/recipe.bash
Normal file
16
tests/integration/helpers/recipe.bash
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_fetch_recipe() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo 'forgot to pass argument to function?'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$ABRA_DIR/recipes/$1" ]]; then
|
||||
run mkdir -p "$ABRA_DIR/recipes"
|
||||
assert_success
|
||||
|
||||
run git clone "https://git.coopcloud.tech/coop-cloud/$1" "$ABRA_DIR/recipes/$1"
|
||||
assert_success
|
||||
fi
|
||||
}
|
19
tests/integration/helpers/server.bash
Normal file
19
tests/integration/helpers/server.bash
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
_add_server() {
|
||||
run $ABRA server add "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
}
|
||||
|
||||
_rm_server() {
|
||||
run $ABRA server remove --no-input "$TEST_SERVER"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER"
|
||||
}
|
||||
|
||||
_rm_default_server(){
|
||||
run rm -rf "$ABRA_DIR/servers/default"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/servers/default"
|
||||
}
|
Reference in New Issue
Block a user