diff --git a/cli/app/new.go b/cli/app/new.go index daa818a7..ecd231c8 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -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) } }, diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index da7e5b10..6899270e 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -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 }