From fdd135f62066edf6af0b0a5be5ee5b1e9fdac1e0 Mon Sep 17 00:00:00 2001 From: Edgars Beigarts Date: Wed, 24 Feb 2016 09:28:25 +0200 Subject: [PATCH] Fix exit code for redis:export when SSH_TTY is not present --- commands | 2 ++ tests/service_export.bats | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/commands b/commands index b6b68bf..347ddc3 100755 --- a/commands +++ b/commands @@ -117,7 +117,9 @@ case "$1" in [[ -n $SSH_TTY ]] && stty -opost docker exec "$SERVICE_NAME" bash -c "echo SAVE | redis-cli" > /dev/null 2>&1 docker exec "$SERVICE_NAME" cat /data/dump.rdb + status=$? [[ -n $SSH_TTY ]] && stty opost + exit $status ;; $PLUGIN_COMMAND_PREFIX:import) diff --git a/tests/service_export.bats b/tests/service_export.bats index 7389d79..683a3fc 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -21,9 +21,18 @@ teardown() { assert_contains "${lines[*]}" "service not_existing_service does not exist" } -@test "($PLUGIN_COMMAND_PREFIX:export) success" { +@test "($PLUGIN_COMMAND_PREFIX:export) success with SSH TTY" { export ECHO_DOCKER_COMMAND="true" + export SSH_TTY=`tty` run dokku "$PLUGIN_COMMAND_PREFIX:export" l + assert_exit_status 0 assert_output "docker exec dokku.redis.l cat /data/dump.rdb" } +@test "($PLUGIN_COMMAND_PREFIX:export) success without SSH TTY" { + export ECHO_DOCKER_COMMAND="true" + unset SSH_TTY + run dokku "$PLUGIN_COMMAND_PREFIX:export" l + assert_exit_status 0 + assert_output "docker exec dokku.redis.l cat /data/dump.rdb" +}