Add support for flags on the service:info command

This commit is contained in:
Jose Diaz-Gonzalez
2016-08-28 05:38:03 -04:00
parent f02aaf39d8
commit c806328cc8
5 changed files with 86 additions and 20 deletions

View File

@@ -21,14 +21,46 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:info) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "DSN: mongodb://l:$password@dokku-mongo-l:27017/l"
local password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "mongodb://l:$password@dokku-mongo-l:27017/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: mongodb://test_with_underscores:$password@dokku-mongo-test-with-underscores:27017/test_with_underscores"
local password="$(cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")"
assert_contains "${lines[*]}" "mongodb://test_with_underscores:$password@dokku-mongo-test-with-underscores:27017/test_with_underscores"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores
}
@test "($PLUGIN_COMMAND_PREFIX:info) success with flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
local password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_output "mongodb://l:$password@dokku-mongo-l:27017/l"
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --data-dir
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --exposed-ports
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --links
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --status
assert_success
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --version
assert_success
}
@test "($PLUGIN_COMMAND_PREFIX:info) error when invalid flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --invalid-flag
assert_failure
}

View File

@@ -47,6 +47,14 @@ assert_success() {
fi
}
assert_failure() {
if [[ "$status" -eq 0 ]]; then
flunk "expected failed exit status"
elif [[ "$#" -gt 0 ]]; then
assert_output "$1"
fi
}
assert_exists() {
if [ ! -f "$1" ]; then
flunk "expected file to exist: $1"