parent
b6009057a8
commit
22e4dd7fca
@ -75,9 +75,34 @@ var AppNewCommand = &cobra.Command{
|
|||||||
|
|
||||||
chaosVersion := config.CHAOS_DEFAULT
|
chaosVersion := config.CHAOS_DEFAULT
|
||||||
if internal.Chaos {
|
if internal.Chaos {
|
||||||
recipeVersion = chaosVersion
|
var err error
|
||||||
|
chaosVersion, err = recipe.ChaosVersion()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if !internal.Offline {
|
// 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 {
|
if err := recipe.EnsureUpToDate(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -88,29 +113,29 @@ var AppNewCommand = &cobra.Command{
|
|||||||
if err := recipe.EnsureIsClean(); err != nil {
|
if err := recipe.EnsureIsClean(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var recipeVersions recipePkg.RecipeVersions
|
var recipeVersions recipePkg.RecipeVersions
|
||||||
if recipeVersion == "" {
|
if recipeVersion == "" {
|
||||||
var err error
|
var err error
|
||||||
recipeVersions, _, err = recipe.GetRecipeVersions()
|
recipeVersions, _, err = recipe.GetRecipeVersions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(recipeVersions) > 0 {
|
|
||||||
latest := recipeVersions[len(recipeVersions)-1]
|
|
||||||
for tag := range latest {
|
|
||||||
recipeVersion = tag
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
|
if len(recipeVersions) > 0 {
|
||||||
log.Fatal(err)
|
latest := recipeVersions[len(recipeVersions)-1]
|
||||||
}
|
for tag := range latest {
|
||||||
} else {
|
recipeVersion = tag
|
||||||
if err := recipe.EnsureLatest(); err != nil {
|
}
|
||||||
log.Fatal(err)
|
|
||||||
|
if _, err := recipe.EnsureVersion(recipeVersion); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := recipe.EnsureLatest(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ setup(){
|
|||||||
teardown(){
|
teardown(){
|
||||||
_rm_app
|
_rm_app
|
||||||
_reset_recipe
|
_reset_recipe
|
||||||
|
_reset_tags
|
||||||
|
|
||||||
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "create new app" {
|
@test "create new app" {
|
||||||
@ -185,3 +189,50 @@ teardown(){
|
|||||||
assert_success
|
assert_success
|
||||||
assert_output --partial 'test_pass_one'
|
assert_output --partial 'test_pass_one'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "app new from chaos recipe" {
|
||||||
|
currentHash=$(_get_current_hash)
|
||||||
|
latestRelease=$(_latest_release)
|
||||||
|
|
||||||
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
assert_success
|
||||||
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
|
||||||
|
run $ABRA app new "$TEST_RECIPE" \
|
||||||
|
--no-input \
|
||||||
|
--server "$TEST_SERVER" \
|
||||||
|
--domain "$TEST_APP_DOMAIN" \
|
||||||
|
--secrets \
|
||||||
|
--chaos
|
||||||
|
assert_success
|
||||||
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_output --partial "version: $latestRelease"
|
||||||
|
assert_output --partial "chaos: ${currentHash:0:8}"
|
||||||
|
|
||||||
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
assert_equal "$(_git_status)" "?? foo"
|
||||||
|
}
|
||||||
|
|
||||||
|
# bats test_tags=slow
|
||||||
|
@test "app new, no releases, from chaos recipe" {
|
||||||
|
_remove_tags
|
||||||
|
|
||||||
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
assert_success
|
||||||
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
|
||||||
|
run $ABRA app new "$TEST_RECIPE" \
|
||||||
|
--no-input \
|
||||||
|
--server "$TEST_SERVER" \
|
||||||
|
--domain "$TEST_APP_DOMAIN" \
|
||||||
|
--secrets \
|
||||||
|
--chaos
|
||||||
|
assert_success
|
||||||
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
||||||
|
assert_output --partial "version: unknown"
|
||||||
|
assert_output --partial "chaos: ${currentHash:0:8}"
|
||||||
|
|
||||||
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||||
|
assert_equal "$(_git_status)" "?? foo"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user