Skip to content

Commit

Permalink
fix: update tests to properly handle case where app is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Diaz-Gonzalez committed Feb 21, 2023
1 parent 02a9beb commit 74238b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions common-functions
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/service_link.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,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
Expand All @@ -129,7 +130,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
Expand Down
4 changes: 2 additions & 2 deletions tests/service_unlink.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

0 comments on commit 74238b9

Please sign in to comment.