test: ensure .env version written
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
decentral1se 2025-01-08 14:19:01 +01:00 committed by decentral1se
parent c70b6e72a7
commit 993172d31b
2 changed files with 25 additions and 1 deletions

View File

@ -236,7 +236,16 @@ var AppNewCommand = &cobra.Command{
log.Fatal(err)
}
if err := app.WriteRecipeVersion(recipeVersion, false); err != nil {
if err := app.Recipe.IsDirty(); err != nil {
log.Fatal(err)
}
toWriteVersion := recipeVersion
if internal.Chaos || app.Recipe.Dirty {
toWriteVersion = chaosVersion
}
if err := app.WriteRecipeVersion(toWriteVersion, false); err != nil {
log.Fatalf("writing recipe version failed: %s", err)
}
},

View File

@ -177,6 +177,8 @@ teardown(){
# bats test_tags=slow
@test "generate secrets" {
latestRelease=$(_latest_release)
run $ABRA app new "$TEST_RECIPE" \
--no-input \
--server "$TEST_SERVER" \
@ -188,6 +190,10 @@ teardown(){
run $ABRA app secret ls "$TEST_APP_DOMAIN"
assert_success
assert_output --partial 'test_pass_one'
run grep -q "TYPE=$TEST_RECIPE:${latestRelease}" \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}
# bats test_tags=slow
@ -212,10 +218,15 @@ teardown(){
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_equal "$(_git_status)" "?? foo"
run grep -q "TYPE=$TEST_RECIPE:${currentHash:0:8}+U" \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}
# bats test_tags=slow
@test "app new, no releases, from chaos recipe" {
currentHash=$(_get_current_hash)
_remove_tags
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -235,4 +246,8 @@ teardown(){
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_equal "$(_git_status)" "?? foo"
run grep -q "TYPE=$TEST_RECIPE:${currentHash:0:8}+U" \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}