Split tests into separate files, add secret tests

This commit is contained in:
3wc 2020-10-31 17:06:41 +02:00
parent 2bdfe8baa8
commit f8306b282d
3 changed files with 66 additions and 33 deletions

View File

@ -1,33 +0,0 @@
#!/usr/bin/env bats
@test "docker is available" {
command -v docker
}
@test "abra is executable" {
./abra --help
}
@test "git is available" {
command -v git
}
@test "running in a container" {
ls /etc/alpine-release
}
@test "abra server add/rm works" {
./abra server add swarm.test.com
docker context ls | grep swarm.test.com
./abra server rm swarm.test.com
./abra server add swarm.test.com foobar 12345
./abra server rm swarm.test.com
}
@test "abra app new/rm works" {
./abra server add swarm.test.com
./abra app new --server swarm.test.com --domain traefik.test.com traefik
ls ~/.abra/servers/swarm.test.com/traefik.test.com.env
./abra app traefik.test.com delete --force
}

17
tests/01_environment.bats Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bats
@test "docker is available" {
command -v docker
}
@test "abra is executable" {
./abra --help
}
@test "git is available" {
command -v git
}
@test "running in a container" {
ls /etc/alpine-release
}

49
tests/02_abra.bats Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bats
setup() {
mkdir -p ~/.abra/servers/default
}
teardown() {
rm -rf ~/.abra/servers/default
rm -rf ~/.abra/servers/swarm.test.com
}
@test "abra server add/rm works" {
./abra server add swarm.test.com
docker context ls | grep swarm.test.com
[ -d ~/.abra/servers/swarm.test.com ]
./abra server rm swarm.test.com
./abra server add swarm.test.com foobar 12345
[ -d ~/.abra/servers/swarm.test.com ]
./abra server rm swarm.test.com
}
@test "abra app new/rm works" {
./abra app new --server default --domain traefik.test.com traefik
[ -f ~/.abra/servers/default/traefik.test.com.env ]
# interactive prompt
echo "y" | ./abra app traefik.test.com delete
[ ! -f ~/.abra/servers/default/traefik.test.com.env ]
# --force
./abra app new --server default --domain traefik.test.com traefik
./abra app traefik.test.com delete --force
[ ! -f ~/.abra/servers/default/traefik.test.com.env ]
}
@test "abra app <domain> secret (insert|generate|rm)" {
# TODO 3wc: mock `server new` so we don't endlessly re-test it
./abra app new --server default --domain traefik.test.com traefik
./abra app traefik.test.com secret insert foobar v1 "foobar"
# interactive prompt
echo "y" | ./abra app traefik.test.com secret rm foobar
./abra app traefik.test.com secret insert foobar v1 "foobar"
# prompt
./abra app traefik.test.com secret rm foobar --force
}