All checks were successful
continuous-integration/drone/push Build is passing
201 lines
5.2 KiB
Bash
201 lines
5.2 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
|
|
}
|
|
|
|
teardown(){
|
|
_reset_recipe
|
|
_reset_tags
|
|
if [[ -d "$ABRA_DIR/recipes/foobar" ]]; then
|
|
run rm -rf "$ABRA_DIR/recipes/foobar"
|
|
assert_success
|
|
fi
|
|
}
|
|
|
|
@test "validate recipe argument" {
|
|
run $ABRA recipe sync --no-input
|
|
assert_failure
|
|
|
|
run $ABRA recipe sync DOESNTEXIST --no-input
|
|
assert_failure
|
|
}
|
|
|
|
@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
|
|
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_equal "$(_git_status)" "M compose.yml ?? foo"
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
@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?'
|
|
}
|
|
|
|
@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'
|
|
|
|
# NOTE(d1): ensure the latest tag is the one we expect
|
|
_remove_tags
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \
|
|
-a "0.3.0+1.21.0" -m "fake: 0.3.0+1.21.0"
|
|
assert_success
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.1\+1\.2.*'
|
|
}
|
|
|
|
@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.*'
|
|
|
|
# NOTE(d1): ensure the latest tag is the one we expect
|
|
_remove_tags
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \
|
|
-a "0.3.0+1.21.0" -m "fake: 0.3.0+1.21.0"
|
|
assert_success
|
|
|
|
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\.4\.0\+1\.2.*'
|
|
}
|
|
|
|
@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'
|
|
}
|
|
|
|
@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'
|
|
}
|
|
|
|
@test "sync with no tags or previous release" {
|
|
_remove_tags
|
|
|
|
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'
|
|
|
|
# NOTE(d1): ensure the latest tag is the one we expect
|
|
_remove_tags
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag \
|
|
-a "0.3.0+1.21.0" -m "fake: 0.3.0+1.21.0"
|
|
assert_success
|
|
|
|
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
|
assert_success
|
|
|
|
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
|
assert_success
|
|
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.3\.1\+1\.2.*'
|
|
}
|
|
|
|
@test "sync recipe without input fails with prompt" {
|
|
run $ABRA recipe new foobar
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/foobar"
|
|
|
|
run $ABRA recipe sync foobar --no-input --patch
|
|
assert_failure
|
|
assert_output --partial "input required for initial version"
|
|
}
|
|
|
|
@test "sync new recipe: development release" {
|
|
run $ABRA recipe new foobar
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/foobar"
|
|
|
|
run bash -c "echo 0.1.0 | $ABRA recipe sync foobar --patch"
|
|
assert_success
|
|
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=0\.1\.0\+1\.2.*'
|
|
}
|
|
|
|
@test "sync new recipe: public release" {
|
|
run $ABRA recipe new foobar
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/foobar"
|
|
|
|
run bash -c "echo 1.0.0 | $ABRA recipe sync foobar --patch"
|
|
assert_success
|
|
assert_output --regexp 'coop-cloud\.\$\{STACK_NAME\}\.version=1\.0\.0\+1\.2.*'
|
|
}
|
|
|
|
@test "sync newly created recipe with no version label" {
|
|
run $ABRA recipe new foobar
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/foobar"
|
|
|
|
run sed -i 's/- "coop-cloud.${STACK_NAME}.version="/#- "coop-cloud.${STACK_NAME}.version="/g' \
|
|
"$ABRA_DIR/recipes/foobar/compose.yml"
|
|
assert_success
|
|
|
|
run bash -c "echo 0.1.0 | $ABRA recipe sync foobar --patch"
|
|
assert_failure
|
|
assert_output --partial "automagic insertion not supported yet"
|
|
}
|