fix: recipe workflow with integration tests
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -1,8 +1,105 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
# TODO(d1): implement
|
||||
@test "validate recipe argument" {
|
||||
run $ABRA recipe upgrade --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'no recipe name provided'
|
||||
|
||||
run $ABRA recipe upgrade DOESNTEXIST --no-input
|
||||
assert_failure
|
||||
assert_output --partial 'unable to validate recipe'
|
||||
}
|
||||
|
||||
@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 recipe upgrade "$TEST_RECIPE" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'can upgrade service: app'
|
||||
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if unstaged changes" {
|
||||
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
assert_success
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
assert_success
|
||||
assert_output --partial 'foo'
|
||||
|
||||
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input
|
||||
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 "ensure up to date" {
|
||||
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 recipe upgrade "$TEST_RECIPE" --no-input
|
||||
assert_success
|
||||
assert_output --partial 'can upgrade service: app'
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" status
|
||||
refute_output --partial 'behind 3'
|
||||
}
|
||||
|
||||
@test "only one of -x/y/z flags" {
|
||||
run $ABRA recipe upgrade "$TEST_RECIPE" --no-input -x -y
|
||||
assert_failure
|
||||
assert_output --partial 'you can only use one of'
|
||||
}
|
||||
|
||||
@test "upgrade patch" {
|
||||
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'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "upgrade minor" {
|
||||
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 --minor
|
||||
assert_success
|
||||
|
||||
run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff
|
||||
assert_success
|
||||
assert_output --regexp 'image: nginx:1.2.*'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
Reference in New Issue
Block a user