-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" | ||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x | ||
source "$PLUGIN_BASE_PATH/common/functions" | ||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" | ||
|
||
service-reset-cmd() { | ||
#E delete all data in $PLUGIN_COMMAND_PREFIX service named lolipop | ||
#E dokku $PLUGIN_COMMAND_PREFIX:reset lolipop | ||
#A service, service to run command against | ||
#F -f|--force, force delete without asking for confirmation | ||
declare desc="delete all data in $PLUGIN_SERVICE service" | ||
local cmd="$PLUGIN_COMMAND_PREFIX:reset" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 | ||
declare SERVICE="$1" FORCE_FLAG="$2" | ||
|
||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" | ||
verify_service_name "$SERVICE" | ||
|
||
local message="This command will delete all data in $SERVICE $PLUGIN_SERVICE service." | ||
prompt_confirmation "$message" "$SERVICE" "$FORCE_FLAG" | ||
|
||
service_reset "$SERVICE" | ||
} | ||
|
||
service-reset-cmd "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bats | ||
load test_helper | ||
|
||
setup() { | ||
dokku "$PLUGIN_COMMAND_PREFIX:create" l | ||
} | ||
|
||
teardown() { | ||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l | ||
} | ||
|
||
@test "($PLUGIN_COMMAND_PREFIX:reset) success with --force" { | ||
run dokku --force "$PLUGIN_COMMAND_PREFIX:reset" l | ||
assert_contains "${lines[*]}" "All l data deleted" | ||
assert_success | ||
} | ||
|
||
@test "($PLUGIN_COMMAND_PREFIX:reset) error when there are no arguments" { | ||
run dokku "$PLUGIN_COMMAND_PREFIX:reset" | ||
assert_contains "${lines[*]}" "Please specify a name for the service" | ||
assert_failure | ||
} | ||
|
||
@test "($PLUGIN_COMMAND_PREFIX:reset) error when service does not exist" { | ||
run dokku "$PLUGIN_COMMAND_PREFIX:reset" not_existing_service | ||
assert_contains "${lines[*]}" "service not_existing_service does not exist" | ||
assert_failure | ||
} |