From 4e8995cc0e1fc5f8982d8af5c9f98f597d8a89b6 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Fri, 27 Dec 2024 21:55:01 +0100 Subject: [PATCH] fix: moar integration test patches See https://git.coopcloud.tech/toolshed/organising/issues/650 --- cli/app/new.go | 21 ++++++++++++++------- tests/integration/app_new.bats | 4 ++-- tests/integration/app_secret.bats | 3 +-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cli/app/new.go b/cli/app/new.go index 27e8d012..8a0b53b1 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -64,7 +64,7 @@ var AppNewCommand = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { recipe := internal.ValidateRecipe(args, cmd.Name()) - var version string + var recipeVersion string if !internal.Chaos { if err := recipe.EnsureIsClean(); err != nil { log.Fatal(err) @@ -75,7 +75,6 @@ var AppNewCommand = &cobra.Command{ } } - var recipeVersion string if len(args) == 2 { recipeVersion = args[1] } @@ -89,10 +88,10 @@ var AppNewCommand = &cobra.Command{ if len(recipeVersions) > 0 { latest := recipeVersions[len(recipeVersions)-1] for tag := range latest { - version = tag + recipeVersion = tag } - if _, err := recipe.EnsureVersion(version); err != nil { + if _, err := recipe.EnsureVersion(recipeVersion); err != nil { log.Fatal(err) } } else { @@ -107,6 +106,14 @@ var AppNewCommand = &cobra.Command{ } } + if internal.Chaos && recipeVersion == "" { + var err error + recipeVersion, err = recipe.ChaosVersion() + if err != nil { + log.Fatal(err) + } + } + if err := ensureServerFlag(); err != nil { log.Fatal(err) } @@ -188,7 +195,7 @@ var AppNewCommand = &cobra.Command{ headers := []string{"SERVER", "DOMAIN", "RECIPE", "VERSION"} table.Headers(headers...) - table.Row(newAppServer, appDomain, recipe.Name, version) + table.Row(newAppServer, appDomain, recipe.Name, recipeVersion) log.Infof("new app '%s' created 🌞", recipe.Name) @@ -221,8 +228,8 @@ var AppNewCommand = &cobra.Command{ log.Fatal(err) } - log.Debugf("choosing %s as version to save to env file", version) - if err := app.WriteRecipeVersion(version, false); err != nil { + log.Debugf("choosing %s as version to save to env file", recipeVersion) + if err := app.WriteRecipeVersion(recipeVersion, false); err != nil { log.Fatalf("writing new recipe version in env file: %s", err) } }, diff --git a/tests/integration/app_new.bats b/tests/integration/app_new.bats index 4d1f52db..c3be967c 100644 --- a/tests/integration/app_new.bats +++ b/tests/integration/app_new.bats @@ -49,7 +49,7 @@ teardown(){ assert_equal $(_get_tag_hash 0.3.0+1.21.0) $(_get_current_hash) - run grep -q "RECIPE=$TEST_RECIPE:0.3.0+1.21.0" \ + run grep -q "TYPE=$TEST_RECIPE:0.3.0+1.21.0" \ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" assert_success } @@ -65,7 +65,7 @@ teardown(){ currentHash=$(_get_current_hash) assert_equal 1e83340e ${currentHash:0:8} - run grep -q "RECIPE=$TEST_RECIPE:1e83340e" \ + run grep -q "TYPE=$TEST_RECIPE:1e83340e" \ "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" assert_success } diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index edb506d2..f72df97f 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -231,8 +231,7 @@ teardown(){ run $ABRA app secret rm "$TEST_APP_DOMAIN" test_pass_one --all assert_failure - assert_output --partial 'cannot use' - assert_output --partial "'--all' together" + assert_output --regexp 'cannot use .* together' } @test "rm: single secret no match" {