abra/tests/integration/app_version.bats

99 lines
2.2 KiB
Bash

#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
_add_server
_new_app
}
teardown_file(){
_rm_app
_rm_server
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
@test "validate app argument" {
run $ABRA app version
assert_failure
assert_output --partial 'no app provided'
run $ABRA app version DOESNTEXIST
assert_failure
assert_output --partial 'cannot find app'
}
@test "error if not deployed" {
run $ABRA app version "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'is not deployed'
}
# bats test_tags=slow
@test "error if version unknown" {
run sed -i '/coop-cloud.${STACK_NAME}.version=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --chaos
assert_success
run $ABRA app version "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'failed to determine'
_checkout_recipe "$TEST_RECIPE"
_undeploy_app
}
# bats test_tags=slow
@test "error if no version in catalogue" {
_deploy_app
run $ABRA app version "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'could not retrieve deployed version'
_undeploy_app
}
@test "list version" {
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$latestVersion" ];
run $ABRA app new gitea \
--no-input \
--server "$TEST_SERVER" \
--domain "gitea.$TEST_SERVER" \
--secrets
assert_success
run $ABRA app deploy "gitea.$TEST_SERVER" \
--no-input --no-converge-checks
assert_success
run $ABRA app version "gitea.$TEST_SERVER"
assert_success
assert_output --partial "$latestVersion"
run $ABRA app undeploy "gitea.$TEST_SERVER" --no-input
assert_success
run $ABRA app secret remove "gitea.$TEST_SERVER" --all --no-input
assert_success
# NOTE(d1): to let the stack come down before nuking volumes
sleep 5
run $ABRA app volume remove "gitea.$TEST_SERVER" --no-input
assert_success
run $ABRA app remove "gitea.$TEST_SERVER" --no-input
assert_success
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env"
}