forked from toolshed/abra
test: moar integration tests [ci skip]
This commit is contained in:
80
tests/integration/app_backup.bats
Normal file
80
tests/integration/app_backup.bats
Normal file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
setup_file() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
_add_server
|
||||
_new_app
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
_rm_app
|
||||
_rm_server
|
||||
}
|
||||
|
||||
setup() {
|
||||
load "$PWD/tests/integration/helpers/common"
|
||||
_common_setup
|
||||
}
|
||||
|
||||
@test "retrieve recipe if missing" {
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
|
||||
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
assert_success
|
||||
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN"
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "detect backup labels" {
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" --debug
|
||||
assert_failure
|
||||
assert_output --partial 'no containers matching'
|
||||
|
||||
assert_output --partial 'detected backup paths'
|
||||
assert_output --partial 'detected pre-hook command'
|
||||
assert_output --partial 'detected post-hook command'
|
||||
}
|
||||
|
||||
@test "error if backups not enabled" {
|
||||
run sed -i '/backupbot.backup=true/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'no backup config for app'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
@test "error if backup paths not configured" {
|
||||
run sed -i '/backupbot.backup.path=.*/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
||||
assert_success
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_failure
|
||||
assert_output --partial 'backup paths are empty for app?'
|
||||
|
||||
_checkout_recipe "$TEST_RECIPE"
|
||||
}
|
||||
|
||||
# bats test_tags=slow
|
||||
@test "backup single service" {
|
||||
_deploy_app
|
||||
|
||||
run $ABRA app backup "$TEST_APP_DOMAIN" app
|
||||
assert_success
|
||||
assert_output --partial 'running backup for the app service'
|
||||
|
||||
sanitisedDomainName="${TEST_APP_DOMAIN//./_}"
|
||||
assert_output --partial "_$sanitisedDomainName_app"
|
||||
|
||||
assert_exists "$ABRA_DIR/backups"
|
||||
assert bash -c "ls $ABRA_DIR/backups | grep -q $1_$sanitisedDomainName_app"
|
||||
|
||||
_undeploy_app
|
||||
}
|
Reference in New Issue
Block a user