From cba3e2436599dad02ff4d8dc36842d24fd37ef3e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 21 Feb 2023 00:48:22 -0500 Subject: [PATCH] fix: update tests to properly handle case where app is not running --- common-functions | 2 ++ tests/service_link.bats | 7 ++++--- tests/service_unlink.bats | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common-functions b/common-functions index 7472f84..0b3b952 100755 --- a/common-functions +++ b/common-functions @@ -633,6 +633,7 @@ service_link() { plugn trigger service-action post-link "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "$APP" if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]] || [[ "$SERVICE_RESTART_APPS" == "false" ]]; then config_set --no-restart "$APP" "${ALIAS}_URL=$SERVICE_URL" + dokku_log_verbose "Skipping restart of linked app" else config_set "$APP" "${ALIAS}_URL=$SERVICE_URL" fi @@ -977,6 +978,7 @@ service_unlink() { plugn trigger service-action post-unlink "$PLUGIN_COMMAND_PREFIX" "$SERVICE" "$APP" if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]] || [[ "$SERVICE_RESTART_APPS" == "false" ]]; then config_unset --no-restart "$APP" "${LINK[@]}" + dokku_log_verbose "Skipping restart of linked app" else config_unset "$APP" "${LINK[@]}" fi diff --git a/tests/service_link.bats b/tests/service_link.bats index d7a4a4b..d728d8b 100755 --- a/tests/service_link.bats +++ b/tests/service_link.bats @@ -117,11 +117,12 @@ teardown() { dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app } + @test "($PLUGIN_COMMAND_PREFIX:link) respects --no-restart" { - run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app --no-restart + run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app echo "output: $output" echo "status: $status" - assert_output_contains "Restarting app my-app" 1 + assert_output_contains "Skipping restart of linked app" 0 assert_success run dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app @@ -132,7 +133,7 @@ teardown() { run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app --no-restart echo "output: $output" echo "status: $status" - assert_output_contains "Restarting app my-app" 0 + assert_output_contains "Skipping restart of linked app" assert_success run dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app diff --git a/tests/service_unlink.bats b/tests/service_unlink.bats index 8156ab2..637a00e 100755 --- a/tests/service_unlink.bats +++ b/tests/service_unlink.bats @@ -56,7 +56,7 @@ teardown() { run dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app echo "output: $output" echo "status: $status" - assert_output_contains "Restarting app my-app" 1 + assert_output_contains "Skipping restart of linked app" 0 assert_success run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app @@ -67,6 +67,6 @@ teardown() { run dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app --no-restart echo "output: $output" echo "status: $status" - assert_output_contains "Restarting app my-app" 0 + assert_output_contains "Skipping restart of linked app" assert_success }