Use temporary ABRA_DIr in tests

This commit is contained in:
3wc 2020-12-27 21:53:44 +02:00
parent 73e5e64b9a
commit fdf6334ed3

View File

@ -1,37 +1,37 @@
#!/usr/bin/env bats #!/usr/bin/env bats
setup() { setup() {
mkdir -p ~/.abra/servers/default export ABRA_DIR=$(mktemp -d)
mkdir -p $ABRA_DIR/servers/default
} }
teardown() { teardown() {
rm -rf ~/.abra/servers/default rm -rf "$ABRA_DIR"
rm -rf ~/.abra/servers/swarm.test.com
} }
@test "abra server add/rm works" { @test "abra server add/rm works" {
./abra server add swarm.test.com ./abra server add swarm.test.com
docker context ls | grep swarm.test.com docker context ls | grep swarm.test.com
[ -d ~/.abra/servers/swarm.test.com ] [ -d $ABRA_DIR/servers/swarm.test.com ]
./abra server swarm.test.com rm ./abra server swarm.test.com rm
./abra server add swarm.test.com foobar 12345 ./abra server add swarm.test.com foobar 12345
[ -d ~/.abra/servers/swarm.test.com ] [ -d $ABRA_DIR/servers/swarm.test.com ]
./abra server swarm.test.com rm ./abra server swarm.test.com rm
} }
@test "abra app new/rm works" { @test "abra app new/rm works" {
./abra app new --server default --domain traefik.test.com traefik ./abra app new --server default --domain traefik.test.com traefik
[ -f ~/.abra/servers/default/traefik.test.com.env ] [ -f $ABRA_DIR/servers/default/traefik.test.com.env ]
# interactive prompt # interactive prompt
echo "y" | ./abra app traefik.test.com delete echo "y" | ./abra app traefik.test.com delete
[ ! -f ~/.abra/servers/default/traefik.test.com.env ] [ ! -f $ABRA_DIR/servers/default/traefik.test.com.env ]
# --force # --force
./abra app new --server default --domain traefik.test.com traefik ./abra app new --server default --domain traefik.test.com traefik
./abra app traefik.test.com delete --force ./abra app traefik.test.com delete --force
[ ! -f ~/.abra/servers/default/traefik.test.com.env ] [ ! -f $ABRA_DIR/servers/default/traefik.test.com.env ]
} }
@test "abra app <domain> secret (insert|generate|rm)" { @test "abra app <domain> secret (insert|generate|rm)" {