120 lines
3.0 KiB
Bash
120 lines
3.0 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
setup_file(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
_add_server
|
|
_new_app
|
|
}
|
|
|
|
teardown_file(){
|
|
_rm_server
|
|
}
|
|
|
|
setup(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
}
|
|
|
|
@test "validate app argument" {
|
|
run $ABRA app check
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app check DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
}
|
|
|
|
@test "retrieve recipe if missing" {
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'all necessary environment variables defined'
|
|
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
|
}
|
|
|
|
@test "bail if unstaged changes and no --chaos" {
|
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
@test "do not bail if unstaged changes and --chaos" {
|
|
run bash -c 'echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"'
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
|
|
assert_success
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
@test "ensure recipe up to date if no --offline" {
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --partial 'behind 3'
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
refute_output --partial 'behind 3'
|
|
|
|
_reset_recipe "$TEST_RECIPE"
|
|
}
|
|
|
|
@test "ensure recipe not up to date if --offline" {
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" reset --hard HEAD~3
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --partial 'behind 3'
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN" --offline
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_output --partial 'behind 3'
|
|
|
|
_reset_recipe "$TEST_RECIPE"
|
|
}
|
|
|
|
@test "error if missing .env.sample" {
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/.env.sample"
|
|
assert_success
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
|
|
assert_failure
|
|
assert_output --partial '.env.sample does not exist?'
|
|
|
|
_checkout_recipe "$TEST_RECIPE"
|
|
}
|
|
|
|
@test "error if missing env var" {
|
|
run bash -c 'echo "NEW_VAR=foo" >> "$ABRA_DIR/recipes/$TEST_RECIPE/.env.sample"'
|
|
assert_success
|
|
|
|
run $ABRA app check "$TEST_APP_DOMAIN" --chaos
|
|
assert_failure
|
|
assert_output --partial \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env is missing NEW_VAR"
|
|
|
|
_checkout_recipe "$TEST_RECIPE"
|
|
}
|