Files
dokku-postgres/tests/service_info.bats
2015-09-29 18:51:49 +02:00

35 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bats
load test_helper
setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
}
teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
}
@test "($PLUGIN_COMMAND_PREFIX:info) error when there are no arguments" {
run dokku "$PLUGIN_COMMAND_PREFIX:info"
assert_contains "${lines[*]}" "Please specify a name for the service"
}
@test "($PLUGIN_COMMAND_PREFIX:info) error when service does not exist" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" not_existing_service
assert_contains "${lines[*]}" "service not_existing_service does not exist"
}
@test "($PLUGIN_COMMAND_PREFIX:info) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "DSN: postgres://postgres:$password@dokku-postgres-l:5432/l"
}
@test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" {
dokku "$PLUGIN_COMMAND_PREFIX:create" test_with_underscores
run dokku "$PLUGIN_COMMAND_PREFIX:info" test_with_underscores
password="$(cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")"
assert_contains "${lines[*]}" "DSN: postgres://postgres:$password@dokku-postgres-test-with-underscores:5432/test_with_underscores"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores
}