124 lines
2.9 KiB
Bash
124 lines
2.9 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 recipe argument" {
|
|
run $ABRA recipe sync --no-input
|
|
assert_failure
|
|
assert_output --partial 'no recipe name provided'
|
|
|
|
run $ABRA recipe sync DOESNTEXIST --no-input
|
|
assert_failure
|
|
assert_output --partial 'unable to validate recipe'
|
|
}
|
|
|
|
@test "allow unstaged changes" {
|
|
run echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
|
assert_success
|
|
assert_output --partial 'foo'
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
|
assert_success
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
@test "detect unstaged label changes" {
|
|
run $ABRA recipe fetch "$TEST_RECIPE"
|
|
assert_success
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --patch
|
|
assert_success
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --patch
|
|
assert_success
|
|
assert_output --partial 'is already set, nothing to do?'
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
# NOTE(d1): relies on only 3 versions being published for the $TEST_RECIPE.
|
|
@test "sync patch label bump" {
|
|
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --patch
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --partial 'image: nginx:1.21.6'
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --partial 'coop-cloud.${STACK_NAME}.version=0.2.1+1.21.6'
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
@test "sync minor label bump" {
|
|
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --regexp 'image: nginx:1.2.*'
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --minor
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.2\.0\+1\.2.*'
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
@test "error if --no-input and no initial version" {
|
|
_remove_tags
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
|
assert_failure
|
|
assert_output --partial 'unable to continue'
|
|
assert_output --partial 'initial version'
|
|
|
|
_reset_tags
|
|
}
|
|
|
|
@test "output label sync only once" {
|
|
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --regexp 'image: nginx:1.2.*'
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --minor
|
|
assert_success
|
|
assert_line --index 0 --partial 'synced label'
|
|
refute_line --index 1 --partial 'synced label'
|
|
|
|
_checkout_recipe
|
|
}
|