From ce1aa3d8705ad0291f0cb3e45888892d99ebc714 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 9 Nov 2025 10:41:32 +0100 Subject: [PATCH] test: ensure recipe sync is robust --- tests/integration/recipe_sync.bats | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/integration/recipe_sync.bats b/tests/integration/recipe_sync.bats index 33edaa0c..c82bbc3b 100644 --- a/tests/integration/recipe_sync.bats +++ b/tests/integration/recipe_sync.bats @@ -19,6 +19,10 @@ setup(){ teardown(){ _reset_recipe _reset_tags + if [[ -d "$ABRA_DIR/recipes/foobar" ]]; then + run rm -rf "$ABRA_DIR/recipes/foobar" + assert_success + fi } @test "validate recipe argument" { @@ -126,3 +130,71 @@ teardown(){ assert_line --index 0 --partial 'synced label' refute_line --index 1 --partial 'synced label' } + +@test "sync with no tags or previous release" { + _remove_tags + + 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.21.6' + + # NOTE(d1): ensure the latest tag is the one we expect + _remove_tags + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \ + -a "0.3.0+1.21.0" -m "fake: 0.3.0+1.21.0" + assert_success + + run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch + assert_success + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff + assert_success + assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.1\+1\.2.*' +} + +@test "sync recipe without input fails with prompt" { + run $ABRA recipe new foobar + assert_success + assert_exists "$ABRA_DIR/recipes/foobar" + + run $ABRA recipe sync foobar --no-input --patch + assert_failure + assert_output --partial "input required for initial version" +} + +@test "sync new recipe: development release" { + run $ABRA recipe new foobar + assert_success + assert_exists "$ABRA_DIR/recipes/foobar" + + run bash -c "echo 0.1.0 | $ABRA recipe sync foobar --patch" + assert_success + assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.1\.0\+1\.2.*' +} + +@test "sync new recipe: public release" { + run $ABRA recipe new foobar + assert_success + assert_exists "$ABRA_DIR/recipes/foobar" + + run bash -c "echo 1.0.0 | $ABRA recipe sync foobar --patch" + assert_success + assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=1\.0\.0\+1\.2.*' +} + +@test "sync newly created recipe with no version label" { + run $ABRA recipe new foobar + assert_success + assert_exists "$ABRA_DIR/recipes/foobar" + + run sed -i 's/- "coop-cloud.${STACK_NAME}.version="/#- "coop-cloud.${STACK_NAME}.version="/g' \ + "$ABRA_DIR/recipes/foobar/compose.yml" + assert_success + + run bash -c "echo 0.1.0 | $ABRA recipe sync foobar --patch" + assert_failure + assert_output --partial "automagic insertion not supported yet" +}