From c65be64e7d6b0d4d18a8f5e4b4435af10a4be07e Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 24 Jul 2024 16:08:37 +0200 Subject: [PATCH] fix: dont checkout version for `abra app undeploy` See https://git.coopcloud.tech/coop-cloud/organising/issues/628 --- cli/app/undeploy.go | 4 +-- tests/integration/app_undeploy.bats | 50 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/cli/app/undeploy.go b/cli/app/undeploy.go index 43ea2415..c48b7aad 100644 --- a/cli/app/undeploy.go +++ b/cli/app/undeploy.go @@ -68,6 +68,7 @@ var appUndeployCommand = cli.Command{ Flags: []cli.Flag{ internal.DebugFlag, internal.NoInputFlag, + internal.OfflineFlag, pruneFlag, }, Before: internal.SubCommandBefore, @@ -82,9 +83,6 @@ any previously attached volumes as eligible for pruning once undeployed. Passing "-p/--prune" does not remove those volumes.`, Action: func(c *cli.Context) error { app := internal.ValidateApp(c) - if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil { - log.Fatal(err) - } stackName := app.StackName() cl, err := client.New(app.Server) diff --git a/tests/integration/app_undeploy.bats b/tests/integration/app_undeploy.bats index 79fa80bf..6058a59e 100644 --- a/tests/integration/app_undeploy.bats +++ b/tests/integration/app_undeploy.bats @@ -18,6 +18,7 @@ setup(){ } teardown(){ + _reset_recipe _undeploy_app } @@ -31,12 +32,61 @@ teardown(){ assert_output --partial 'cannot find app' } +# bats test_tags=slow +@test "ensure recipe up to date if no --offline" { + _deploy_app + + wantHash=$(_get_n_hash 3) + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3 + assert_success + + assert_equal $(_get_current_hash) "$wantHash" + + run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input + assert_success + + assert_equal $(_get_head_hash) $(_get_current_hash) +} + +# bats test_tags=slow +@test "ensure recipe not up to date if --offline" { + _deploy_app + + _ensure_env_version "0.1.0+1.20.0" + latestRelease=$(_latest_release) + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d "$latestRelease" + assert_success + + run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input --offline + assert_success + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -l + refute_output --partial "$latestRelease" +} + @test "error if not deployed" { run $ABRA app undeploy "$TEST_APP_DOMAIN" assert_failure assert_output --partial 'is not deployed' } +# bats test_tags=slow +@test "do not bail if unstaged changes (only query runtime)" { + _deploy_app + + run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_success + assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + + run $ABRA app undeploy "$TEST_APP_DOMAIN" --no-input + assert_success + + run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" + assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" +} + # bats test_tags=slow @test "undeploy app" { run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input