diff --git a/tests/integration/app_backup.bats b/tests/integration/app_backup.bats index 4f10772a..a91d6e13 100644 --- a/tests/integration/app_backup.bats +++ b/tests/integration/app_backup.bats @@ -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" diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index 26fc4052..3dd50ee3 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -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 diff --git a/tests/integration/app_cp.bats b/tests/integration/app_cp.bats index 4123b530..2687e9d4 100644 --- a/tests/integration/app_cp.bats +++ b/tests/integration/app_cp.bats @@ -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 diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 5c04f49a..edee25d9 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -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 +} diff --git a/tests/integration/app_list.bats b/tests/integration/app_list.bats index 0f62e1ee..dd38d10f 100644 --- a/tests/integration/app_list.bats +++ b/tests/integration/app_list.bats @@ -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 diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index 282b24cc..4ce67680 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -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 \ diff --git a/tests/integration/app_ps.bats b/tests/integration/app_ps.bats index edc60cb5..b2a9987c 100644 --- a/tests/integration/app_ps.bats +++ b/tests/integration/app_ps.bats @@ -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 diff --git a/tests/integration/app_remove.bats b/tests/integration/app_remove.bats index 63626fd0..e9595db9 100644 --- a/tests/integration/app_remove.bats +++ b/tests/integration/app_remove.bats @@ -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 diff --git a/tests/integration/app_restart.bats b/tests/integration/app_restart.bats index 18ee570f..b01bb7b3 100644 --- a/tests/integration/app_restart.bats +++ b/tests/integration/app_restart.bats @@ -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 diff --git a/tests/integration/app_restore.bats b/tests/integration/app_restore.bats index ed0d6d63..de477230 100644 --- a/tests/integration/app_restore.bats +++ b/tests/integration/app_restore.bats @@ -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 diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index 2f2c246e..b3601741 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -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 } diff --git a/tests/integration/app_run.bats b/tests/integration/app_run.bats index 8980abf4..abcd1aa0 100644 --- a/tests/integration/app_run.bats +++ b/tests/integration/app_run.bats @@ -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 diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index 79e529cc..2f629047 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -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 diff --git a/tests/integration/app_services.bats b/tests/integration/app_services.bats index 9fee6b1d..c63ce2df 100644 --- a/tests/integration/app_services.bats +++ b/tests/integration/app_services.bats @@ -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 diff --git a/tests/integration/app_undeploy.bats b/tests/integration/app_undeploy.bats index 051eb458..9d435203 100644 --- a/tests/integration/app_undeploy.bats +++ b/tests/integration/app_undeploy.bats @@ -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 diff --git a/tests/integration/app_upgrade.bats b/tests/integration/app_upgrade.bats index 2a660e36..a2575102 100644 --- a/tests/integration/app_upgrade.bats +++ b/tests/integration/app_upgrade.bats @@ -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 } diff --git a/tests/integration/app_version.bats b/tests/integration/app_version.bats index b4cd3910..a8f95f6c 100644 --- a/tests/integration/app_version.bats +++ b/tests/integration/app_version.bats @@ -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 } diff --git a/tests/integration/app_volume.bats b/tests/integration/app_volume.bats index 9c0c9d5b..5b4ff600 100644 --- a/tests/integration/app_volume.bats +++ b/tests/integration/app_volume.bats @@ -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 diff --git a/tests/integration/setup_suite.bash b/tests/integration/setup_suite.bash index f0438864..c52b71b8 100644 --- a/tests/integration/setup_suite.bash +++ b/tests/integration/setup_suite.bash @@ -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