From 008582c3d9c74c5cdf4e9a6996cadfc8336be53e Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 27 Dec 2024 20:44:07 +0100 Subject: [PATCH] test: fixes for test suite post-cobra migrate See https://git.coopcloud.tech/toolshed/organising/issues/650 --- cli/app/cmd.go | 1 + tests/integration/app_backup.bats | 188 ------------------ tests/integration/app_check.bats | 2 - tests/integration/app_cmd.bats | 28 +-- tests/integration/app_config.bats | 2 - tests/integration/app_cp.bats | 18 +- tests/integration/app_deploy.bats | 2 - tests/integration/app_logs.bats | 2 - tests/integration/app_new.bats | 6 - tests/integration/app_ps.bats | 2 - tests/integration/app_remove.bats | 2 - tests/integration/app_restart.bats | 3 - tests/integration/app_restore.bats | 272 -------------------------- tests/integration/app_rollback.bats | 2 - tests/integration/app_run.bats | 6 +- tests/integration/app_secret.bats | 3 - tests/integration/app_services.bats | 2 - tests/integration/app_undeploy.bats | 2 - tests/integration/app_upgrade.bats | 2 - tests/integration/app_volume.bats | 2 - tests/integration/autocomplete.bats | 30 --- tests/integration/helpers/file.bash | 4 +- tests/integration/recipe_release.bats | 2 - tests/integration/recipe_sync.bats | 2 - tests/integration/recipe_upgrade.bats | 2 - 25 files changed, 12 insertions(+), 575 deletions(-) delete mode 100644 tests/integration/app_backup.bats delete mode 100644 tests/integration/app_restore.bats delete mode 100644 tests/integration/autocomplete.bats diff --git a/cli/app/cmd.go b/cli/app/cmd.go index 9176bd4ba..1cb0d6630 100644 --- a/cli/app/cmd.go +++ b/cli/app/cmd.go @@ -59,6 +59,7 @@ does not).`, // "app" should not be there, but there is no reliable way to detect arg // count when the user can pass an arbitrary amount of recipe command // arguments + return nil } if !(len(args) >= 3) { diff --git a/tests/integration/app_backup.bats b/tests/integration/app_backup.bats deleted file mode 100644 index c0435dff0..000000000 --- a/tests/integration/app_backup.bats +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env bash - -setup_file() { - load "$PWD/tests/integration/helpers/common" - _common_setup - _add_server - _new_app -} - -teardown_file() { - _rm_app - _rm_server - _reset_recipe -} - -setup() { - load "$PWD/tests/integration/helpers/common" - _common_setup -} - -teardown(){ - _undeploy_app -} - -@test "retrieve recipe if missing" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" - assert_success - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" - - run $ABRA app backup "$TEST_APP_DOMAIN" - assert_failure - assert_output --partial 'no containers matching' - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" -} - -@test "bail if unstaged changes and no --chaos" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_success - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_success - assert_output --partial 'foo' - - run $ABRA app backup "$TEST_APP_DOMAIN" app - assert_failure - assert_output --partial 'locally unstaged changes' - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - _checkout_recipe -} - -# bats test_tags=slow -@test "do not bail if unstaged changes and --chaos" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"' - assert_success - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_success - assert_output --partial 'foo' - - run $ABRA app deploy "$TEST_APP_DOMAIN" --chaos --no-input - assert_success - - run $ABRA app backup "$TEST_APP_DOMAIN" app --chaos - assert_success - assert_output --partial 'running backup for the app service' - - _undeploy_app - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" -} - -@test "ensure recipe up to date if no --offline" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - 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' - - run $ABRA app backup "$TEST_APP_DOMAIN" --debug - assert_failure - assert_output --partial 'no containers matching' - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - refute_output --partial 'behind 3' - - _reset_recipe -} - -@test "ensure recipe not up to date if --offline" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - 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' - - run $ABRA app backup "$TEST_APP_DOMAIN" --debug --offline - assert_failure - assert_output --partial 'no containers matching' - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial 'behind 3' - - 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' - - _reset_recipe -} - -@test "detect backup labels" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run $ABRA app backup "$TEST_APP_DOMAIN" --debug - assert_failure - assert_output --partial 'no containers matching' - - assert_output --partial 'detected backup paths' - assert_output --partial 'detected pre-hook command' - assert_output --partial 'detected post-hook command' -} - -@test "error if backups not enabled" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run sed -i '/backupbot.backup=true/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" - assert_success - - run $ABRA app backup "$TEST_APP_DOMAIN" app --chaos - assert_failure - assert_output --partial 'no backup config for app' - - _checkout_recipe -} - -@test "error if backup paths not configured" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run sed -i '/backupbot.backup.path=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" - assert_success - - run $ABRA app backup "$TEST_APP_DOMAIN" app --chaos - assert_failure - assert_output --partial 'backup paths are empty for app?' - - _checkout_recipe -} - -# bats test_tags=slow -@test "backup single service" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - _deploy_app - - run $ABRA app backup "$TEST_APP_DOMAIN" app - assert_success - assert_output --partial 'running backup for the app service' - - sanitisedDomainName="${TEST_APP_DOMAIN//./_}" - assert_output --partial "_$sanitisedDomainName_app" - - assert_exists "$ABRA_DIR/backups" - assert bash -c "ls $ABRA_DIR/backups | grep -q $1_$sanitisedDomainName_app" - - _undeploy_app -} diff --git a/tests/integration/app_check.bats b/tests/integration/app_check.bats index b5be82eb6..b96b02153 100644 --- a/tests/integration/app_check.bats +++ b/tests/integration/app_check.bats @@ -26,11 +26,9 @@ teardown(){ @test "validate app argument" { run $ABRA app check assert_failure - assert_output --partial 'no app provided' run $ABRA app check DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "retrieve recipe if missing" { diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index 673063d48..60a4d7454 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -24,32 +24,12 @@ teardown(){ _undeploy_app } -# bats test_tags=slow -@test "autocomplete" { - run $ABRA app cmd --generate-bash-completion - assert_success - assert_output "$TEST_APP_DOMAIN" - - run $ABRA app cmd "$TEST_APP_DOMAIN" --generate-bash-completion - assert_success - assert_output "app" - - run $ABRA app cmd "$TEST_APP_DOMAIN" app --generate-bash-completion - assert_success - assert_output "test_cmd -test_cmd_arg -test_cmd_args -test_cmd_export" -} - @test "validate app argument" { run $ABRA app cmd assert_failure - assert_output --partial 'no app provided' run $ABRA app cmd DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "retrieve recipe if missing" { @@ -123,13 +103,11 @@ test_cmd_export" @test "error if missing arguments without passing --local" { run $ABRA app cmd "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'missing arguments' } @test "error if missing arguments when passing --local" { run $ABRA app cmd --local "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'missing arguments' } @test "cannot use --local and --user at same time" { @@ -162,17 +140,13 @@ test_cmd_export" } @test "run command with single arg" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/581" - run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_arg -- bing assert_success assert_output --partial 'bing' } @test "run command with several args" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/581" - - run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_args -- bong bang + run $ABRA app cmd --local "$TEST_APP_DOMAIN" test_cmd_args bong bang assert_success assert_output --partial 'bong bang' } diff --git a/tests/integration/app_config.bats b/tests/integration/app_config.bats index 6b4002483..82ca1bda5 100644 --- a/tests/integration/app_config.bats +++ b/tests/integration/app_config.bats @@ -18,9 +18,7 @@ setup(){ @test "validate app argument" { run $ABRA app config assert_failure - assert_output --partial 'no app provided' run $ABRA app config DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } diff --git a/tests/integration/app_cp.bats b/tests/integration/app_cp.bats index 62c993487..9042d47be 100644 --- a/tests/integration/app_cp.bats +++ b/tests/integration/app_cp.bats @@ -29,21 +29,17 @@ teardown(){ @test "validate app argument" { run $ABRA app cp assert_failure - assert_output --partial 'no app provided' run $ABRA app cp DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "error if missing src/dest arguments" { run $ABRA app cp "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'missing argument' run $ABRA app cp "$TEST_APP_DOMAIN" myfile.txt assert_failure - assert_output --partial 'missing argument' } @test "either src/dest has correct syntax" { @@ -159,7 +155,7 @@ teardown(){ # bats test_tags=slow @test "copy container file to local directory" { - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo foo > /etc/myfile.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo foo > /etc/myfile.txt" assert_success run $ABRA app cp "$TEST_APP_DOMAIN" app:/etc/myfile.txt "$BATS_TMPDIR" @@ -170,7 +166,7 @@ teardown(){ # bats test_tags=slow @test "copy container file to local file" { - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo foo > /etc/myfile.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo foo > /etc/myfile.txt" assert_success run $ABRA app cp "$TEST_APP_DOMAIN" app:/etc/myfile.txt "$BATS_TMPDIR/myfile.txt" @@ -181,7 +177,7 @@ teardown(){ # bats test_tags=slow @test "copy container file to local file and rename" { - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo foo > /etc/myfile.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo foo > /etc/myfile.txt" assert_success run $ABRA app cp "$TEST_APP_DOMAIN" app:/etc/myfile.txt "$BATS_TMPDIR/myfile2.txt" @@ -192,10 +188,10 @@ teardown(){ # bats test_tags=slow @test "copy container directory to local directory" { - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo foo > /etc/myfile.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo foo > /etc/myfile.txt" assert_success - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo bar > /etc/myfile2.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo bar > /etc/myfile2.txt" assert_success mkdir "$BATS_TMPDIR/mydir" @@ -209,10 +205,10 @@ teardown(){ # bats test_tags=slow @test "copy container files to local directory" { - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo foo > /etc/myfile.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo foo > /etc/myfile.txt" assert_success - run $ABRA app run "$TEST_APP_DOMAIN" app bash -c "echo bar > /etc/myfile2.txt" + run $ABRA app run "$TEST_APP_DOMAIN" app -- bash -c "echo bar > /etc/myfile2.txt" assert_success mkdir "$BATS_TMPDIR/mydir" diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index a5fd6e817..3594afa6b 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -32,11 +32,9 @@ teardown(){ @test "validate app argument" { run $ABRA app deploy assert_failure - assert_output --partial 'no app provided' run $ABRA app deploy DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "bail if unstaged changes and no --chaos" { diff --git a/tests/integration/app_logs.bats b/tests/integration/app_logs.bats index 8760fdcc8..d12223de4 100644 --- a/tests/integration/app_logs.bats +++ b/tests/integration/app_logs.bats @@ -20,11 +20,9 @@ setup(){ @test "validate app argument" { run $ABRA app logs assert_failure - assert_output --partial 'no app provided' run $ABRA app logs DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "error if not deployed" { diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index 9dc773427..c3be967c4 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -22,12 +22,6 @@ teardown(){ _reset_recipe } -@test "autocomplete" { - run $ABRA app new --generate-bash-completion - assert_success - assert_output --partial "traefik" -} - @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 fad17c781..41da4753b 100644 --- a/tests/integration/app_ps.bats +++ b/tests/integration/app_ps.bats @@ -24,11 +24,9 @@ teardown(){ @test "validate app argument" { run $ABRA app ps assert_failure - assert_output --partial 'no app provided' run $ABRA app ps DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } # bats test_tags=slow diff --git a/tests/integration/app_remove.bats b/tests/integration/app_remove.bats index c4ab0f7df..0a1d02819 100644 --- a/tests/integration/app_remove.bats +++ b/tests/integration/app_remove.bats @@ -28,11 +28,9 @@ teardown(){ @test "validate app argument" { run $ABRA app deploy assert_failure - assert_output --partial 'no app provided' run $ABRA app deploy DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "do not show ALERTA warning if --force / --no-input" { diff --git a/tests/integration/app_restart.bats b/tests/integration/app_restart.bats index b41c9689c..2c09f5eea 100644 --- a/tests/integration/app_restart.bats +++ b/tests/integration/app_restart.bats @@ -24,17 +24,14 @@ teardown(){ @test "validate app argument" { run $ABRA app restart assert_failure - assert_output --partial 'no app provided' run $ABRA app restart DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "error if service missing" { run $ABRA app restart "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'missing ' } @test "error if not deployed" { diff --git a/tests/integration/app_restore.bats b/tests/integration/app_restore.bats deleted file mode 100644 index 2500d420d..000000000 --- a/tests/integration/app_restore.bats +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/env bash - -setup_file(){ - load "$PWD/tests/integration/helpers/common" - _common_setup - _add_server - _new_app -} - -teardown_file(){ - _rm_app - _rm_server - _reset_recipe -} - -setup(){ - load "$PWD/tests/integration/helpers/common" - _common_setup -} - -teardown(){ - _undeploy_app -} - -@test "validate app argument" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run $ABRA app restore - assert_failure - assert_output --partial 'no app provided' - - run $ABRA app restore DOESNTEXIST - assert_failure - assert_output --partial 'cannot find app' -} - -@test "retrieve recipe if missing" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE" - assert_success - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE" - - run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST - assert_failure - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE" -} - -@test "bail if unstaged changes and no --chaos" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_success - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_success - assert_output --partial 'foo' - - run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST - assert_failure - assert_output --partial 'locally unstaged changes' - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - _checkout_recipe -} - -# bats test_tags=slow -@test "do not bail if unstaged changes and --chaos" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"' - assert_success - assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_success - assert_output --partial 'foo' - - run touch "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.txt" - - run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.tar.gz" - - run $ABRA app deploy "$TEST_APP_DOMAIN" --chaos --no-input - assert_success - - run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" \ - --debug --chaos - assert_success - assert_output --partial 'restore config detected' - assert_output --partial 'detected pre-hook command' - assert_output --partial 'detected post-hook command' - - run $ABRA app run "$TEST_APP_DOMAIN" app ls "$BATS_TMPDIR" - assert_success - assert_output --partial 'foo.txt' - - _undeploy_app - - run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - - _checkout_recipe -} - -@test "ensure recipe up to date if no --offline" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - 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' - - run $ABRA app restore "$TEST_APP_DOMAIN" app - assert_failure - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "up to date" -} - -@test "ensure recipe not up to date if --offline" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - 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 --regexp 'behind .* 3 commits' - - run $ABRA app restore "$TEST_APP_DOMAIN" app --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 - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status - assert_output --partial "HEAD detached at $latestCommit" -} - -@test "error if missing service" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run $ABRA app restore "$TEST_APP_DOMAIN" - assert_failure - assert_output --partial 'missing ' - - run $ABRA app restore "$TEST_APP_DOMAIN" app - assert_failure - assert_output --partial 'missing ' -} - -@test "error if file doesn't exist" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run $ABRA app restore "$TEST_APP_DOMAIN" app DOESNTEXIST - assert_failure - assert_output --partial "doesn't exist" -} - -# bats test_tags=slow -@test "detect labels if restore enabled" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run touch "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.txt" - - run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.tar.gz" - - _deploy_app - - run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" --debug - assert_success - assert_output --partial 'restore config detected' - assert_output --partial 'detected pre-hook command' - assert_output --partial 'detected post-hook command' - - _undeploy_app -} - -# bats test_tags=slow -@test "no error if restore not enabled" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run sed -i '/backupbot.restore=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" - assert_success - - run touch "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.txt" - - run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.tar.gz" - - run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input --chaos - assert_success - - run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" \ - --debug --chaos - assert_success - refute_output --partial 'restore config detected' - refute_output --partial 'detected pre-hook command' - refute_output --partial 'detected post-hook command' - - _undeploy_app - - _checkout_recipe -} - -# bats test_tags=slow -@test "error if service doesn't exist" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run touch "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.txt" - - run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.tar.gz" - - _deploy_app - - run $ABRA app restore "$TEST_APP_DOMAIN" DOESNTEXIST "$BATS_TMPDIR/foo.tar.gz" --debug - assert_failure - assert_output --partial 'no containers matching' - - _undeploy_app -} - -# bats test_tags=slow -@test "restore backup" { - skip "https://git.coopcloud.tech/coop-cloud/organising/issues/583" - - run touch "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.txt" - - run tar -cvf "$BATS_TMPDIR/foo.tar.gz" "$BATS_TMPDIR/foo.txt" - assert_success - assert_exists "$BATS_TMPDIR/foo.tar.gz" - - _deploy_app - - run $ABRA app restore "$TEST_APP_DOMAIN" app "$BATS_TMPDIR/foo.tar.gz" --debug - assert_success - assert_output --partial 'restore config detected' - assert_output --partial 'detected pre-hook command' - assert_output --partial 'detected post-hook command' - - run $ABRA app run "$TEST_APP_DOMAIN" app ls "$BATS_TMPDIR" - assert_success - assert_output --partial 'foo.txt' - - _undeploy_app -} diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index 55be3dcab..d7c63241f 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -26,11 +26,9 @@ teardown(){ @test "validate app argument" { run $ABRA app rollback assert_failure - assert_output --partial 'no app provided' run $ABRA app rollback DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "retrieve recipe if missing" { diff --git a/tests/integration/app_run.bats b/tests/integration/app_run.bats index d9e51d409..7318104d9 100644 --- a/tests/integration/app_run.bats +++ b/tests/integration/app_run.bats @@ -24,21 +24,17 @@ teardown(){ @test "validate app argument" { run $ABRA app run assert_failure - assert_output --partial 'no app provided' run $ABRA app run DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "error if missing service" { run $ABRA app run "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'no provided' run $ABRA app run "$TEST_APP_DOMAIN" app assert_failure - assert_output --partial 'no provided' } # bats test_tags=slow @@ -54,7 +50,7 @@ teardown(){ @test "run command" { _deploy_app - run $ABRA app run "$TEST_APP_DOMAIN" app ls / + run $ABRA app run "$TEST_APP_DOMAIN" app -- ls / assert_success assert_output --partial 'root' } diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index ffc38588f..0aaf4a4d6 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -35,7 +35,6 @@ teardown(){ @test "generate: validate arguments" { run $ABRA app secret generate assert_failure - assert_output --partial 'no app provided' run $ABRA app secret generate DOESNTEXIST assert_failure @@ -43,7 +42,6 @@ teardown(){ run $ABRA app secret generate "$TEST_APP_DOMAIN" assert_failure - assert_output --partial 'missing arguments' run $ABRA app secret generate "$TEST_APP_DOMAIN" testSecret testVersion --all assert_failure @@ -89,7 +87,6 @@ teardown(){ run $ABRA app secret generate "$TEST_APP_DOMAIN" --all assert_failure assert_output --partial 'missing version' - } @test "generate: use version from app env" { diff --git a/tests/integration/app_services.bats b/tests/integration/app_services.bats index 3cab9bce9..2d770cb08 100644 --- a/tests/integration/app_services.bats +++ b/tests/integration/app_services.bats @@ -25,11 +25,9 @@ teardown(){ @test "validate app argument" { run $ABRA app services assert_failure - assert_output --partial 'no app provided' run $ABRA app services DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "error if not deployed" { diff --git a/tests/integration/app_undeploy.bats b/tests/integration/app_undeploy.bats index 6058a59ed..d4c5d7b2b 100644 --- a/tests/integration/app_undeploy.bats +++ b/tests/integration/app_undeploy.bats @@ -25,11 +25,9 @@ teardown(){ @test "validate app argument" { run $ABRA app undeploy assert_failure - assert_output --partial 'no app provided' run $ABRA app undeploy DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } # bats test_tags=slow diff --git a/tests/integration/app_upgrade.bats b/tests/integration/app_upgrade.bats index 532243017..231683f30 100644 --- a/tests/integration/app_upgrade.bats +++ b/tests/integration/app_upgrade.bats @@ -26,11 +26,9 @@ teardown(){ @test "validate app argument" { run $ABRA app upgrade assert_failure - assert_output --partial 'no app provided' run $ABRA app upgrade DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } # bats test_tags=slow diff --git a/tests/integration/app_volume.bats b/tests/integration/app_volume.bats index cbd929613..1cce638b9 100644 --- a/tests/integration/app_volume.bats +++ b/tests/integration/app_volume.bats @@ -24,11 +24,9 @@ teardown(){ @test "ls validate app argument" { run $ABRA app volume ls assert_failure - assert_output --partial 'no app provided' run $ABRA app volume ls DOESNTEXIST assert_failure - assert_output --partial 'cannot find app' } @test "list no volumes" { diff --git a/tests/integration/autocomplete.bats b/tests/integration/autocomplete.bats deleted file mode 100644 index 3f3e7d7aa..000000000 --- a/tests/integration/autocomplete.bats +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -setup(){ - load "$PWD/tests/integration/helpers/common" - _common_setup -} - -@test "bash autocompletion" { - run $ABRA autocomplete bash - assert_success - assert_exists "$ABRA_DIR/autocompletion/bash" -} - -@test "zsh autocompletion" { - run $ABRA autocomplete zsh - assert_success - assert_exists "$ABRA_DIR/autocompletion/zsh" -} - -@test "fish autocompletion" { - run $ABRA autocomplete fish - assert_success - assert_exists "$ABRA_DIR/autocompletion/fish" -} - -@test "fizsh autocompletion" { - run $ABRA autocomplete fizsh - assert_success - assert_exists "$ABRA_DIR/autocompletion/zsh" -} diff --git a/tests/integration/helpers/file.bash b/tests/integration/helpers/file.bash index 5cb918691..c65a6af31 100644 --- a/tests/integration/helpers/file.bash +++ b/tests/integration/helpers/file.bash @@ -4,7 +4,7 @@ _mkfile() { } _mkfile_remote() { - run $ABRA app run "$TEST_APP_DOMAIN" app "bash -c \"echo $2 > $1\"" + run $ABRA app run "$TEST_APP_DOMAIN" app -- "bash -c \"echo $2 > $1\"" assert_success } @@ -19,6 +19,6 @@ _rm() { } _rm_remote() { - run "$ABRA" app run "$TEST_APP_DOMAIN" app rm -rf "$1" + run "$ABRA" app run "$TEST_APP_DOMAIN" app -- rm -rf "$1" assert_success } diff --git a/tests/integration/recipe_release.bats b/tests/integration/recipe_release.bats index e8c0df2c7..52a9e1a5e 100644 --- a/tests/integration/recipe_release.bats +++ b/tests/integration/recipe_release.bats @@ -25,11 +25,9 @@ teardown() { @test "validate recipe argument" { run $ABRA recipe release --no-input assert_failure - assert_output --partial 'no recipe name provided' run $ABRA recipe release DOESNTEXIST --no-input assert_failure - assert_output --partial 'unable to clone DOESNTEXIST' } @test "release patch bump" { diff --git a/tests/integration/recipe_sync.bats b/tests/integration/recipe_sync.bats index 8f4019058..9914372e9 100644 --- a/tests/integration/recipe_sync.bats +++ b/tests/integration/recipe_sync.bats @@ -24,11 +24,9 @@ teardown(){ @test "validate recipe argument" { run $ABRA recipe sync --no-input assert_failure - assert_output --partial 'no recipe name provided' run $ABRA recipe sync DOESNTEXIST --no-input assert_failure - assert_output --partial 'unable to clone DOESNTEXIST' } @test "allow unstaged changes" { diff --git a/tests/integration/recipe_upgrade.bats b/tests/integration/recipe_upgrade.bats index 3edd76142..e7d4664e1 100644 --- a/tests/integration/recipe_upgrade.bats +++ b/tests/integration/recipe_upgrade.bats @@ -24,11 +24,9 @@ teardown(){ @test "validate recipe argument" { run $ABRA recipe upgrade --no-input assert_failure - assert_output --partial 'no recipe name provided' run $ABRA recipe upgrade DOESNTEXIST --no-input assert_failure - assert_output --partial 'unable to clone DOESNTEXIST' } @test "retrieve recipe if missing" {