test: less fragile integration suite [ci skip]

See coop-cloud/organising#584
See coop-cloud/organising#595
This commit is contained in:
2024-06-22 16:40:07 +02:00
parent a9ce2106c6
commit 2014cd6622
39 changed files with 249 additions and 425 deletions

View File

@ -19,10 +19,8 @@ setup(){
}
teardown(){
# https://github.com/bats-core/bats-core/issues/383#issuecomment-738628888
if [[ -z "${BATS_TEST_COMPLETED}" ]]; then
_undeploy_app
fi
_undeploy_app
_reset_recipe
}
@test "validate app argument" {
@ -46,40 +44,32 @@ teardown(){
}
@test "ensure recipe up to date if no --offline" {
wantHash=$(_get_n_hash 3)
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 --regexp 'behind .* 3 commits'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_failure
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --partial "up to date"
assert_equal $(_get_current_hash) $(_get_head_hash)
}
@test "ensure recipe not up to date if --offline" {
latestCommit="$(git -C "$ABRA_DIR/recipes/$TEST_RECIPE" rev-parse --short HEAD)"
refute [ -z "$latestCommit" ];
wantHash=$(_get_n_hash 3)
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 --regexp 'behind .* 3 commits'
assert_equal $(_get_current_hash) "$wantHash"
run $ABRA app rollback "$TEST_APP_DOMAIN" \
--no-input --no-converge-checks --offline
assert_failure
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_output --regexp 'behind .* 3 commits'
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" checkout "$latestCommit"
assert_success
_reset_recipe "$TEST_RECIPE"
assert_equal $(_get_current_hash) $wantHash
}
@test "bail if unstaged changes and no --chaos" {
@ -133,7 +123,7 @@ teardown(){
run $ABRA app deploy "$TEST_APP_DOMAIN" \
--no-input --chaos
assert_success
assert_output --partial "$latestCommit"
assert_output --partial "${latestCommit}"
assert_output --partial 'chaos'
run $ABRA app rollback "$TEST_APP_DOMAIN" \
@ -141,8 +131,6 @@ teardown(){
assert_success
assert_output --partial "$latestCommit"
assert_output --partial 'chaos'
_undeploy_app
}
# bats test_tags=slow
@ -156,10 +144,6 @@ teardown(){
--no-input --chaos --chaos --no-converge-checks
assert_failure
assert_output --partial 'failed lint checks'
_undeploy_app
_checkout_recipe
}
@test "error if not already deployed" {
@ -177,8 +161,6 @@ teardown(){
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
@ -190,8 +172,6 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks
assert_failure
assert_output --partial 'is not a downgrade'
_undeploy_app
}
@test "bail out if specific version and chaos" {
@ -210,8 +190,6 @@ teardown(){
run $ABRA app rollback "$TEST_APP_DOMAIN" --no-input --no-converge-checks
assert_success
assert_output --partial "0.1.0+1.20.0"
_undeploy_app
}
# bats test_tags=slow
@ -223,6 +201,4 @@ teardown(){
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
}