diff --git a/tests/integration/app_backup.bats b/tests/integration/app_backup.bats index abd3f697..3a8d9f0c 100644 --- a/tests/integration/app_backup.bats +++ b/tests/integration/app_backup.bats @@ -53,7 +53,7 @@ teardown(){ run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow @@ -78,7 +78,7 @@ teardown(){ run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "ensure recipe up to date if no --offline" { @@ -142,7 +142,7 @@ teardown(){ assert_failure assert_output --partial 'no backup config for app' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "error if backup paths not configured" { @@ -153,7 +153,7 @@ teardown(){ assert_failure assert_output --partial 'backup paths are empty for app?' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow diff --git a/tests/integration/app_check.bats b/tests/integration/app_check.bats index 1982016d..dd52ee25 100644 --- a/tests/integration/app_check.bats +++ b/tests/integration/app_check.bats @@ -103,7 +103,7 @@ setup(){ assert_failure assert_output --partial '.env.sample does not exist?' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "error if missing env var" { @@ -115,5 +115,5 @@ setup(){ assert_output --partial \ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env is missing NEW_VAR" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } diff --git a/tests/integration/app_cmd.bats b/tests/integration/app_cmd.bats index cd3d53e1..39cfbd44 100644 --- a/tests/integration/app_cmd.bats +++ b/tests/integration/app_cmd.bats @@ -132,7 +132,7 @@ teardown(){ assert_failure assert_output --partial "$ABRA_DIR/recipes/$TEST_RECIPE/abra.sh does not exist" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "error if missing command" { diff --git a/tests/integration/app_deploy.bats b/tests/integration/app_deploy.bats index 3ba3f485..ed705362 100644 --- a/tests/integration/app_deploy.bats +++ b/tests/integration/app_deploy.bats @@ -51,7 +51,7 @@ teardown(){ run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow @@ -174,7 +174,7 @@ teardown(){ assert_failure assert_output --partial 'failed lint checks' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow diff --git a/tests/integration/app_restore.bats b/tests/integration/app_restore.bats index de477230..641a18e9 100644 --- a/tests/integration/app_restore.bats +++ b/tests/integration/app_restore.bats @@ -60,7 +60,7 @@ teardown(){ run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow @@ -100,7 +100,7 @@ teardown(){ run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo" assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "ensure recipe up to date if no --offline" { @@ -202,7 +202,7 @@ teardown(){ _undeploy_app - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } # bats test_tags=slow diff --git a/tests/integration/app_rollback.bats b/tests/integration/app_rollback.bats index e71ac190..64afce27 100644 --- a/tests/integration/app_rollback.bats +++ b/tests/integration/app_rollback.bats @@ -158,7 +158,7 @@ teardown(){ _undeploy_app - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "error if not already deployed" { diff --git a/tests/integration/app_upgrade.bats b/tests/integration/app_upgrade.bats index a2575102..376a75e2 100644 --- a/tests/integration/app_upgrade.bats +++ b/tests/integration/app_upgrade.bats @@ -59,7 +59,7 @@ teardown(){ assert_failure assert_output --partial 'failed lint checks' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe _undeploy_app } diff --git a/tests/integration/app_version.bats b/tests/integration/app_version.bats index a8f95f6c..50dd76bf 100644 --- a/tests/integration/app_version.bats +++ b/tests/integration/app_version.bats @@ -53,7 +53,7 @@ teardown(){ assert_failure assert_output --partial 'failed to determine' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe _undeploy_app } diff --git a/tests/integration/recipe_lint.bats b/tests/integration/recipe_lint.bats index 094495d1..b600a3c2 100644 --- a/tests/integration/recipe_lint.bats +++ b/tests/integration/recipe_lint.bats @@ -67,12 +67,11 @@ setup() { 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" { - 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 @@ -85,11 +84,7 @@ setup() { 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 "recipe lint warns on error" { @@ -103,5 +98,5 @@ setup() { run $ABRA recipe lint "$TEST_RECIPE" --chaos assert_success --partial 'watch out, some critical errors are present' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } diff --git a/tests/integration/recipe_release.bats b/tests/integration/recipe_release.bats index 6fe78305..356e1264 100644 --- a/tests/integration/recipe_release.bats +++ b/tests/integration/recipe_release.bats @@ -26,20 +26,14 @@ setup(){ assert_output --partial 'unable to validate recipe' } +# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE. @test "release patch bump" { - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list - assert_success - assert_output '0.1.0+1.20.0' - - run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"' - assert_success - run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --partial 'image: nginx:1.20.2' + assert_output --partial 'image: nginx:1.21.6' run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch assert_success @@ -47,7 +41,7 @@ setup(){ run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.1.1+1.20.2' + assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6' run $ABRA recipe release "$TEST_RECIPE" --no-input --patch assert_success @@ -55,27 +49,15 @@ setup(){ run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list assert_success - assert_output --partial '0.1.0+1.20.0' - assert_output --partial '0.1.1+1.20.2' + assert_output --partial '0.2.1+1.21.6' - _checkout_recipe "$TEST_RECIPE" - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~1 - assert_success - - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d '0.1.1+1.20.2' - assert_success - assert_output --partial "Deleted tag '0.1.1+1.20.2'" + _reset_recipe } +# NOTE(d1): this test can't assert hardcoded versions since we upgrade a minor +# version which could be anything in the future. so, we do our best with +# --regexp. @test "release minor bump" { - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list - assert_success - assert_output '0.1.0+1.20.0' - - run bash -c 'grep -q "0.1.0+1.20.0" "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"' - assert_success - run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor assert_success @@ -89,7 +71,7 @@ setup(){ run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*' + assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.0\+1\.2.*' run $ABRA recipe release "$TEST_RECIPE" --no-input --minor assert_success @@ -97,8 +79,7 @@ setup(){ run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag --list assert_success - assert_output --partial '0.1.0+1.20.0' - assert_output --regexp '0\.2\.0\+1\.2.*' + assert_output --regexp '0\.3\.0\+1\.2.*' _reset_recipe "$TEST_RECIPE" } diff --git a/tests/integration/recipe_sync.bats b/tests/integration/recipe_sync.bats index bfc6e09f..f04735f8 100644 --- a/tests/integration/recipe_sync.bats +++ b/tests/integration/recipe_sync.bats @@ -41,7 +41,7 @@ setup(){ assert_success assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo" - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "detect unstaged label changes" { @@ -55,28 +55,26 @@ setup(){ assert_success assert_output --partial 'is already set, nothing to do?' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } +# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE. @test "sync patch label bump" { - run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"' - assert_success - run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --partial 'image: nginx:1.20.2' + assert_output --partial 'image: nginx:1.21.6' run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.1.1+1.20.2' + assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "sync minor label bump" { @@ -94,22 +92,18 @@ setup(){ assert_success assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "error if --no-input and no initial version" { - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d '0.1.0+1.20.0' - assert_success - assert_output --partial "Deleted tag '0.1.0+1.20.0'" + _remove_tags run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch assert_failure assert_output --partial 'unable to continue' assert_output --partial 'initial version' - run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch -a - assert_success - assert_output --partial '[new tag]' + _reset_tags } @test "output label sync only once" { @@ -125,5 +119,5 @@ setup(){ assert_line --index 0 --partial 'synced label' refute_line --index 1 --partial 'synced label' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } diff --git a/tests/integration/recipe_upgrade.bats b/tests/integration/recipe_upgrade.bats index 6e5bbcf0..f282c12a 100644 --- a/tests/integration/recipe_upgrade.bats +++ b/tests/integration/recipe_upgrade.bats @@ -68,6 +68,8 @@ setup(){ run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status refute_output --partial 'behind 3' + + _reset_recipe } @test "only one of -x/y/z flags" { @@ -76,24 +78,19 @@ setup(){ assert_output --partial 'you can only use one of' } +# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE. @test "upgrade patch" { - run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"' - assert_success - run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch assert_success run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff assert_success - assert_output --partial 'image: nginx:1.20.2' + assert_output --partial 'image: nginx:1.21.6' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe } @test "upgrade minor" { - run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"' - assert_success - run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor assert_success @@ -101,5 +98,5 @@ setup(){ assert_success assert_output --regexp 'image: nginx:1.2.*' - _checkout_recipe "$TEST_RECIPE" + _checkout_recipe }