test: test arguments, notes, local tag lookup
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is failing Details

This commit is contained in:
decentral1se 2023-09-23 09:17:24 +02:00
parent 510ce66570
commit 575bfbb0fb
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
19 changed files with 398 additions and 139 deletions

View File

@ -17,6 +17,13 @@ setup() {
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "retrieve recipe if missing" {
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app cmd
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app cp
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app deploy
assert_failure
@ -43,6 +50,8 @@ setup(){
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
_checkout_recipe "$TEST_RECIPE"
}
# bats test_tags=slow
@ -77,25 +86,26 @@ setup(){
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
# NOTE(d1): nuke it to ensure clean git state
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
_fetch_recipe "$TEST_RECIPE"
_undeploy_app
}
# bats test_tags=slow
@test "ensure recipe not up to date if --offline" {
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial 'behind 3'
# NOTE(d1): need to use --chaos to force same commit
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --offline
--no-input --no-converge-checks --chaos --offline
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
@ -103,23 +113,46 @@ setup(){
_undeploy_app
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
# NOTE(d1): nuke it to ensure clean git state
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
_fetch_recipe "$TEST_RECIPE"
}
# bats test_tags=slow
@test "deploy latest commit if no published versions and no --chaos" {
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --no-converge-checks
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
assert_success
refute_output '0'
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | \
xargs -I{} git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d {}'
assert_success
assert_output --partial 'Deleted tag'
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
assert_success
assert_output '0'
# NOTE(d1): need to pass --offline to stop tags being pulled again
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --offline
assert_success
assert_output --partial "$latestCommit"
assert_output --partial 'using latest commit'
refute_output --partial 'chaos'
_undeploy_app
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch --all
assert_success
run bash -c 'git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | wc -l'
assert_success
refute_output '0'
}
# bats test_tags=slow
@ -143,9 +176,11 @@ setup(){
_undeploy_app
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
# NOTE(d1): nuke it to ensure clean git state
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
refute_output --partial 'behind 3'
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
_fetch_recipe "$TEST_RECIPE"
}
# bats test_tags=slow
@ -274,3 +309,18 @@ setup(){
_undeploy_app
}
@test "error if specific version does not exist" {
run $ABRA app deploy "$TEST_APP_DOMAIN" DOESNTEXIST --no-input --no-converge-checks
assert_failure
assert_output --partial "doesn't seem to have version DOESNTEXIST available"
}
# bats test_tags=slow
@test "deploy specific version" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input
assert_success
assert_output --partial "0.2.0+1.21.0"
_undeploy_app
}

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "list without status" {
run $ABRA app ls
assert_success

View File

@ -16,6 +16,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "create new app" {
run $ABRA app new "$TEST_RECIPE" \
--no-input \

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app ps
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app deploy
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app restart
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app restore
assert_failure

View File

@ -8,6 +8,7 @@ setup_file(){
}
teardown_file(){
_rm_app
_rm_server
}
@ -16,8 +17,12 @@ setup(){
_common_setup
}
# TODO(d1): test "no available downgrades" when this is implemented
# https://git.coopcloud.tech/coop-cloud/organising/issues/204
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app rollback
@ -73,8 +78,11 @@ setup(){
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
refute_output --partial 'behind 3'
# NOTE(d1): nuke it to ensure clean git state
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
assert_success
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
_fetch_recipe "$TEST_RECIPE"
}
@test "bail if unstaged changes and no --chaos" {
@ -123,38 +131,21 @@ setup(){
# bats test_tags=slow
@test "ensure same commit if --chaos" {
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout main
assert_success
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
assert_success
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial 'behind 3'
threeCommitsBack="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --chaos
assert_success
refute_output --partial "$latestCommit"
assert_output --partial "$threeCommitsBack"
assert_output --partial "$latestCommit"
assert_output --partial 'chaos'
run $ABRA app rollback "$TEST_APP_DOMAIN" \
--chaos --no-input --no-converge-checks
assert_success
refute_output --partial "$latestCommit"
assert_output --partial "$threeCommitsBack"
assert_output --partial "$latestCommit"
assert_output --partial 'chaos'
_undeploy_app
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
assert_success
refute_output --partial 'behind 3'
}
# bats test_tags=slow
@ -164,7 +155,8 @@ setup(){
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos
run $ABRA app rollback "$TEST_APP_DOMAIN" \
--no-input --chaos --chaos --no-converge-checks
assert_failure
assert_output --partial 'failed lint checks'
@ -174,59 +166,59 @@ setup(){
}
@test "error if not already deployed" {
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --chaos
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input
assert_failure
assert_output --partial 'not deployed'
}
# bats test_tags=slow
@test "error if no published release and no --chaos" {
_deploy_app
@test "no rollback if on oldest version" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "you're on oldest"
_undeploy_app
}
# bats test_tags=slow
@test "error if specific version is not downgrade" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_failure
assert_output --partial 'no published releases'
assert_output --partial 'is not a downgrade'
_undeploy_app
}
# bats test_tags=slow
@test "rollback to previous version" {
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$latestVersion" ];
rollbackVersion=$(jq -r '.gitea.versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$rollbackVersion" ];
run $ABRA app new gitea \
--no-input \
--server "$TEST_SERVER" \
--domain "gitea.$TEST_SERVER" \
--secrets
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env"
assert_output --partial '0.1.1+1.20.2'
run $ABRA app deploy "gitea.$TEST_SERVER" --no-input --no-converge-checks
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestVersion"
assert_output --partial "0.1.0+1.20.0"
run $ABRA app rollback "gitea.$TEST_SERVER" --no-input --no-converge-checks
assert_success
assert_output --partial "$rollbackVersion"
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"
_undeploy_app
}
# bats test_tags=slow
@test "rollback to a version 2 tags behind" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
assert_success
assert_output --partial "0.2.0+1.21.0"
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial "0.1.0+1.20.0"
_undeploy_app
}

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app run
assert_failure

View File

@ -18,6 +18,13 @@ teardown_file(){
_rm_server
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app services
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app undeploy
assert_failure

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app upgrade
assert_failure
@ -28,49 +35,171 @@ setup(){
}
# bats test_tags=slow
@test "upgrade app" {
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$latestVersion" ];
@test "error if specific version is not an upgrade" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
rollbackVersion=$(jq -r '.gitea.versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$rollbackVersion" ];
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input
assert_failure
assert_output --partial 'is not an upgrade'
run $ABRA app new gitea \
_undeploy_app
}
# bats test_tags=slow
@test "no upgrade if lint error" {
_deploy_app
run sed -i '/traefik.enable=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
assert_success
run $ABRA app upgrade "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --chaos
assert_failure
assert_output --partial 'failed lint checks'
_checkout_recipe "$TEST_RECIPE"
_undeploy_app
}
# bats test_tags=slow
@test "no upgrade if on latest version" {
_deploy_app
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "you're on latest"
_undeploy_app
}
# bats test_tags=slow
@test "upgrade to latest catalogue published version" {
appDomain="custom-html.$TEST_SERVER"
run $ABRA app new custom-html \
--no-input \
--server "$TEST_SERVER" \
--domain "gitea.$TEST_SERVER" \
--secrets
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/gitea.$TEST_SERVER.env"
--domain "$appDomain"
run $ABRA app deploy "gitea.$TEST_SERVER" --no-input
oneVersionBack=$(jq -r '."custom-html".versions[-2] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$oneVersionBack" ];
run $ABRA app deploy "$appDomain" "$oneVersionBack" --no-input --no-converge-checks
assert_success
assert_output --partial "$oneVersionsBack"
latestVersion=$(jq -r '."custom-html".versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
refute [ -z "$latestVersion" ];
run $ABRA app upgrade "$appDomain" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestVersion"
run $ABRA app rollback "gitea.$TEST_SERVER" --no-input
assert_success
assert_output --partial "$rollbackVersion"
# NOTE(d1): let runtime settle down before upgrade
sleep 5
run $ABRA app upgrade "gitea.$TEST_SERVER" --no-input
assert_success
assert_output --partial "$latestVersion"
run $ABRA app undeploy "gitea.$TEST_SERVER" --no-input
run $ABRA app undeploy "$appDomain" --no-input
assert_success
run $ABRA app secret remove "gitea.$TEST_SERVER" --all --no-input
# NOTE(d1): to let the stack come down before nuking volumes
sleep 3
run $ABRA app volume remove "$appDomain" --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
run $ABRA app remove "$appDomain" --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"
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$appDomain.env"
}
# bats test_tags=slow
@test "upgrade specific version" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.2.0+1.21.0'
_undeploy_app
}
# bats test_tags=slow
@test "upgrade to latest" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestRelease"
_undeploy_app
}
# bats test_tags=slow
@test "show single release note" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.1+1.20.2'
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestRelease"
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
refute_output --partial 'release notes bar' # 0.1.1+1.20.2
_undeploy_app
}
# bats test_tags=slow
@test "show single release note for specific version" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.1.1+1.20.2" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.1+1.20.2'
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
refute_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}
# bats test_tags=slow
@test "show multiple release notes" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
latestRelease=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l | tail -n 1)
run $ABRA app upgrade "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "$latestRelease"
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}
# bats test_tags=slow
@test "show multiple release notes for specific version" {
run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.1.0+1.20.0'
run $ABRA app upgrade "$TEST_APP_DOMAIN" "0.2.0+1.21.0" --no-input --no-converge-checks
assert_success
assert_output --partial '0.2.0+1.21.0'
assert_output --partial 'release notes bar' # 0.1.1+1.20.2
assert_output --partial 'release notes baz' # 0.2.0+1.21.0
_undeploy_app
}

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "validate app argument" {
run $ABRA app version
assert_failure
@ -61,38 +68,16 @@ setup(){
_undeploy_app
}
# bats test_tags=slow
@test "list version" {
latestVersion=$(jq -r '.gitea.versions[-1] | keys[0]' < "$ABRA_DIR/catalogue/recipes.json")
_deploy_app
latestVersion=$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" git tag | tail -n 1)
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"
run $ABRA app version "$TEST_APP_DOMAIN"
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"
_undeploy_app
}

View File

@ -17,6 +17,13 @@ setup(){
_common_setup
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
}
@test "ls validate app argument" {
run $ABRA app volume ls
assert_failure

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash
setup_suite(){
if [[ -z "${TEST_SERVER}" ]]; then
echo 'set $TEST_SERVER before running the test suite' >&3
if [[ -z "${ABRA_DIR}" ]]; then
echo 'set $ABRA_DIR before running the test suite' >&3
exit 1
fi
if [[ -z "${ABRA_DIR}" ]]; then
echo 'set $ABRA_DIR before running the test suite' >&3
if [[ -z "${TEST_SERVER}" ]]; then
echo 'set $TEST_SERVER before running the test suite' >&3
exit 1
fi
@ -36,6 +36,11 @@ setup_suite(){
}
teardown_suite(){
if [[ -z "${ABRA_DIR}" ]]; then
echo 'set $ABRA_DIR before running the test suite' >&3
exit 1
fi
if [[ -d "$ABRA_DIR" ]]; then
rm -rf "$ABRA_DIR"
fi