54 lines
1.3 KiB
Bash
54 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
setup(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
}
|
|
|
|
@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"
|
|
}
|
|
|
|
@test "error if using domain and --local together" {
|
|
run $ABRA server add "$TEST_SERVER" --local
|
|
assert_failure
|
|
assert_output --partial 'cannot use <domain> and --local together'
|
|
}
|
|
|
|
@test "create local server" {
|
|
run docker swarm init
|
|
assert_success
|
|
|
|
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 added'
|
|
|
|
docker swarm leave --force
|
|
assert_success
|
|
|
|
_rm_default_server
|
|
}
|
|
|
|
@test "create local server fails when no docker swarm" {
|
|
run $ABRA server add --local
|
|
assert_failure
|
|
assert_not_exists "$ABRA_DIR/servers/default"
|
|
assert_output --partial 'swarm mode not enabled on local server'
|
|
}
|
|
|
|
@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"
|
|
}
|