Files
abra/tests/integration/server_add.bats
T
devydaveanddevydave 550c9aa48f
continuous-integration/drone/push Build is passing
test: introduce local integration testing (#902)
This PR adds a declarative integration testing setup which includes 2 local VMs client and server which can be started and stopped via a command. The VMs are run with QEMU and created by https://github.com/microvm-nix/microvm.nix
The key pair is generated for this use case and is safe to commit, it resolves the problem that the readFile function can only be used with git tracked files.

---------

Co-authored-by: devydave <yannick-dev@tutanota.com>
Reviewed-on: #902
Reviewed-by: p4u1 <133+p4u1@noreply.git.coopcloud.tech>
Co-authored-by: devydave <bittedanke@tutanota.com>
2026-10-31 08:28:04 +00:00

67 lines
1.6 KiB
Bash

#!/usr/bin/env bash
setup_file(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
setup(){
load "$PWD/tests/integration/helpers/common"
_common_setup
}
teardown(){
_rm_server
_ensure_swarm
}
# bats test_tags=slow,dns
@test "add new server" {
run $ABRA server add "$TEST_SERVER"
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER"
run $ABRA server ls
assert_output --partial "$TEST_SERVER"
assert bash -c "docker context ls | grep -q $TEST_SERVER"
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/$TEST_SERVER")
assert_equal "$server_dir_perms" "700"
}
@test "error if using name and --local together" {
run $ABRA server add "$TEST_SERVER" --local
assert_failure
assert_output --partial 'cannot use [server] and --local together'
}
@test "create local server" {
run $ABRA server add --local
assert_success
assert_exists "$ABRA_DIR/servers/default"
assert bash -c "docker context ls | grep -q default"
assert_output --partial 'local server successfully added'
server_dir_perms=$(stat -c "%a" "$ABRA_DIR/servers/default")
assert_equal "$server_dir_perms" "700"
}
@test "create local server fails when no docker swarm" {
run docker swarm leave --force
assert_success
run $ABRA server add --local
assert_failure
assert_not_exists "$ABRA_DIR/servers/default"
assert_output --partial 'swarm mode not enabled on local server'
}
# bats test_tags=slow
@test "cleanup when cannot add server" {
run $ABRA server add example.com
assert_failure
assert_not_exists "$ABRA_DIR/servers/example.com"
refute bash -c "docker context ls | grep -q example.com"
}