forked from toolshed/abra
fix: recipe workflow with integration tests
This commit is contained in:
@ -1,39 +1,113 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup() {
|
||||
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 $ABRA recipe fetch matrix-synapse
|
||||
run echo "unstaged changes" >> "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_success
|
||||
|
||||
run echo "unstaged changes" >> "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/matrix-synapse" status
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_success
|
||||
assert_output --partial 'foo'
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
||||
assert_success
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/matrix-synapse/foo"
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "detect unstaged label changes" {
|
||||
run $ABRA recipe fetch matrix-synapse
|
||||
run $ABRA recipe fetch "$TEST_RECIPE"
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
run $ABRA recipe sync "$TEST_RECIPE" --patch
|
||||
assert_success
|
||||
|
||||
run $ABRA recipe sync matrix-synapse --patch
|
||||
run $ABRA recipe sync "$TEST_RECIPE" --patch
|
||||
assert_success
|
||||
assert_output --partial 'is already set, nothing to do?'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
# TODO(d1): implement
|
||||
@test "sync patch label bump" {
|
||||
run bash -c 'cat "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml" | grep -q "0.1.0+1.20.0"'
|
||||
assert_success
|
||||
|
||||
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.20.2'
|
||||
|
||||
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.1.1+1.20.2'
|
||||
|
||||
_checkout_recipe "$TEST_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_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if --no-input and no initial version" {
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" tag -d '0.1.0+1.20.0'
|
||||
assert_success
|
||||
assert_output --partial "Deleted tag '0.1.0+1.20.0'"
|
||||
|
||||
run $ABRA recipe sync "$TEST_RECIPE" --no-input --patch
|
||||
assert_failure
|
||||
assert_output --partial 'unable to continue'
|
||||
assert_output --partial 'initial version'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" fetch -a
|
||||
assert_success
|
||||
assert_output --partial '[new tag]'
|
||||
}
|
||||
|
Reference in New Issue
Block a user