Compare commits

..

2 Commits

Author SHA1 Message Date
4facfea7c2 fix(secret): Checks for enough arguments
All checks were successful
continuous-integration/drone/pr Build is passing
2025-02-10 15:32:57 +01:00
15d6b1a2a5 fix: app new with chaos should just take the local repo as it is (#495)
All checks were successful
continuous-integration/drone/push Build is passing
Fixes #494

Reviewed-on: #495
Co-authored-by: p4u1 <p4u1_f4u1@riseup.net>
Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
2025-02-10 14:00:42 +00:00
4 changed files with 16 additions and 34 deletions

View File

@ -81,35 +81,8 @@ var AppNewCommand = &cobra.Command{
log.Fatal(err)
}
// NOTE(d1): rely on tags as there is no recipe.EnvVersion yet because
// the app has not been fully created. we rely on the local git state of
// the repository
tags, err := recipe.Tags()
if err != nil {
log.Fatal(err)
}
internal.SortVersionsDesc(tags)
if len(tags) == 0 {
// NOTE(d1): this is a new recipe with no released versions
recipeVersion = config.UNKNOWN_DEFAULT
} else {
recipeVersion = tags[len(tags)-1]
}
if err := recipe.IsDirty(); err != nil {
log.Fatal(err)
}
if !internal.Offline && !recipe.Dirty {
if err := recipe.EnsureUpToDate(); err != nil {
log.Fatal(err)
}
}
}
if !internal.Chaos {
recipeVersion = chaosVersion
} else {
if err := recipe.EnsureIsClean(); err != nil {
log.Fatal(err)
}

View File

@ -49,11 +49,11 @@ var AppSecretGenerateCommand = &cobra.Command{
log.Fatal(err)
}
if len(args) == 1 && !generateAllSecrets {
if len(args) <= 2 && !generateAllSecrets {
log.Fatal("missing arguments [secret]/[version] or '--all'")
}
if len(args) > 1 && generateAllSecrets {
if len(args) > 2 && generateAllSecrets {
log.Fatal("cannot use '[secret] [version]' and '--all' together")
}

View File

@ -56,7 +56,7 @@ teardown(){
assert_success
}
@test "create new app with chaos commit" {
@test "create new app with version commit" {
tagHash=$(_get_tag_hash "0.3.0+1.21.0")
run $ABRA app new "$TEST_RECIPE" "$tagHash" \
@ -129,6 +129,10 @@ teardown(){
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_equal "$(_git_status)" "?? foo"
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
assert_success
assert_output --partial 'foo'
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
}
@ -210,7 +214,7 @@ teardown(){
--chaos
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_output --partial "version: $latestRelease"
assert_output --partial "version: ${currentHash:0:8}"
assert_output --partial "chaos: ${currentHash:0:8}"
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
@ -238,7 +242,7 @@ teardown(){
--chaos
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_output --partial "version: unknown"
assert_output --partial "version: ${currentHash:0:8}"
assert_output --partial "chaos: ${currentHash:0:8}"
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"

View File

@ -41,6 +41,11 @@ teardown(){
run $ABRA app secret generate "$TEST_APP_DOMAIN"
assert_failure
assert_output --partial 'missing arguments'
run $ABRA app secret generate "$TEST_APP_DOMAIN" test_pass_one
assert_failure
assert_output --partial 'missing arguments'
run $ABRA app secret generate "$TEST_APP_DOMAIN" testSecret testVersion --all
assert_failure