abra/tests/integration/integration.bats
decentral1se 2f10fb80a8
Some checks reported errors
continuous-integration/drone/pr Build was killed
continuous-integration/drone/push Build was killed
wip: automated integration tests
2023-08-02 11:59:43 +02:00

62 lines
1.9 KiB
Bash

setup() {
load '/usr/lib/bats/bats-support/load'
load '/usr/lib/bats/bats-assert/load'
# get test binaries on $PATH for testing
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
ROOT="$DIR/../.."
source "$DIR/helpers.sh"
_build_abra
}
@test "build test abra" {
run $ROOT/abra -h
assert_output --partial 'The Co-op Cloud command-line utility belt'
}
@test "create new recipe" {
run $ROOT/abra recipe new foobar
assert_output --partial 'Your new foobar recipe has been created'
mkdir -p "$HOME/.abra/servers/example.com"
if ! grep -R -q "example.com" "$HOME/.docker"; then
docker context create --docker host=ssh://foo@example.com:222 example.com
fi
run $ROOT/abra app new foobar \
--no-input \
--server example.com \
--domain foobar.example.com
assert_output --partial 'A new foobar app has been created!'
# TODO: abra app deploy foobar.example.com
# we need an actual server for this to ensure things work maybe we can get
# a donated server from the comrades for this?
rm -r "$HOME/.abra/recipes/foobar"
rm -r "$HOME/.abra/servers/example.com"
}
@test "upgrade and sync a recipe" {
run $ROOT/abra recipe fetch gitea
cd "$HOME/.abra/recipes/gitea" && git checkout "2.3.1+1.20.1-rootless"
run $ROOT/abra recipe upgrade gitea --offline --machine
assert_output --partial '1.20.2-rootless'
# TODO: when passing --patch, there is no output so we can't test against
# anything... we should add info logging when automation flags are passed
# so we can assert
run $ROOT/abra recipe upgrade gitea --offline --patch
run $ROOT/abra recipe sync gitea --offline --patch
assert_output --partial \
'synced label coop-cloud.${STACK_NAME}.version=2.3.2+1.20.2-rootless to service app'
# TODO: assert git output
cd "$HOME/.abra/recipes/gitea" && git checkout . && git checkout master
}