Add tests for every command
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
tests/dokku
|
||||||
|
tests/fixtures
|
||||||
@@ -47,6 +47,15 @@ case "$1" in
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $@ =~ \{\{\.State\..*\}\} ]]; then
|
||||||
|
if [[ $@ =~ \{\{\.State\.Running\}\} ]]; then
|
||||||
|
echo "true"
|
||||||
|
else
|
||||||
|
echo "false"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# running
|
# running
|
||||||
echo "true"
|
echo "true"
|
||||||
;;
|
;;
|
||||||
@@ -66,6 +75,9 @@ case "$1" in
|
|||||||
pull)
|
pull)
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
logs)
|
||||||
|
echo "1:M 08 Sep 07:36:43.544 # Server started, Redis version 3.0.3"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
exit 0
|
|
||||||
32
tests/redis_alias.bats
Executable file
32
tests/redis_alias.bats
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:alias) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:alias"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:alias) error when alias is missing" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:alias" l
|
||||||
|
assert_contains "${lines[*]}" "Please specify an alias for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:alias) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:alias" not_existing_service MY_ALIAS
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:alias) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:alias" l MY_ALIAS
|
||||||
|
new_alias=$(cat "$PLUGIN_DATA_ROOT/l/ALIAS")
|
||||||
|
[[ $new_alias == "MY_ALIAS" ]]
|
||||||
|
}
|
||||||
|
|
||||||
29
tests/redis_connect.bats
Executable file
29
tests/redis_connect.bats
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:connect) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:connect"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:connect) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:connect" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:connect) success" {
|
||||||
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:connect" l
|
||||||
|
assert_output 'docker run -it --link dokku.redis.l:redis --rm redis sh -c exec redis-cli -h "$REDIS_PORT_6379_TCP_ADDR" -p "$REDIS_PORT_6379_TCP_PORT"'
|
||||||
|
}
|
||||||
|
|
||||||
12
tests/redis_create.bats
Executable file
12
tests/redis_create.bats
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:create) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||||
|
assert_contains "${lines[*]}" "container created: l"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:create) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:create"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
27
tests/redis_destroy.bats
Executable file
27
tests/redis_destroy.bats
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:destroy) success with --force" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||||
|
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||||
|
assert_contains "${lines[*]}" "container deleted: l"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:destroy) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:destroy"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:destroy) error when container does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:destroy" non_existing_container
|
||||||
|
assert_contains "${lines[*]}" "Redis service non_existing_container does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:destroy) error when container is linked to an app" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||||
|
dokku apps:create app
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l app
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||||
|
assert_contains "${lines[*]}" "Cannot delete linked service"
|
||||||
|
rm "$DOKKU_ROOT/app" -rf
|
||||||
|
}
|
||||||
30
tests/redis_expose.bats
Executable file
30
tests/redis_expose.bats
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:expose) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:expose) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:expose) success when not providing a custom port" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l
|
||||||
|
[[ "${lines[*]}" =~ exposed\ on\ port\(s\)\ [[:digit:]]+ ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:expose) success when providing a custom port" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242
|
||||||
|
assert_contains "${lines[*]}" "exposed on port(s) 4242"
|
||||||
|
}
|
||||||
25
tests/redis_info.bats
Executable file
25
tests/redis_info.bats
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:info) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:info"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:info) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:info" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:info) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:info" l
|
||||||
|
assert_contains "${lines[*]}" "DSN: redis://172.17.0.34:6379/0"
|
||||||
|
}
|
||||||
38
tests/redis_link.bats
Executable file
38
tests/redis_link.bats
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
dokku apps:create my_app >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
rm "$DOKKU_ROOT/my_app" -rf
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:link"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the app argument is missing" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l
|
||||||
|
assert_contains "${lines[*]}" "Please specify an app to run the command on"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the app does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l not_existing_app
|
||||||
|
assert_contains "${lines[*]}" "App not_existing_app does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my_app
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:link) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||||
|
links=$(cat "$PLUGIN_DATA_ROOT/l/LINKS")
|
||||||
|
assert_equal "$links" "my_app"
|
||||||
|
}
|
||||||
28
tests/redis_list.bats
Executable file
28
tests/redis_list.bats
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:list) with no exposed ports" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:list"
|
||||||
|
assert_contains "${lines[*]}" "l (running)"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:list) with exposed ports" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:list"
|
||||||
|
assert_contains "${lines[*]}" "l (running), exposed port(s): 6379->4242"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:list) when there are no services" {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:list"
|
||||||
|
assert_contains "${lines[*]}" "There are no Redis services"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
34
tests/redis_logs.bats
Executable file
34
tests/redis_logs.bats
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
export ECHO_DOCKER_COMMAND="false"
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:logs) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:logs"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:logs) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:logs" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:logs) success when not tailing" {
|
||||||
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:logs" l
|
||||||
|
assert_output "docker logs --tail 100 testid"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:logs) success when tailing" {
|
||||||
|
export ECHO_DOCKER_COMMAND="true"
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:logs" l -t
|
||||||
|
assert_output "docker logs --follow testid"
|
||||||
|
}
|
||||||
26
tests/redis_restart.bats
Executable file
26
tests/redis_restart.bats
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:restart) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:restart"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:restart) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:restart" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:restart) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:restart" l
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
26
tests/redis_start.bats
Executable file
26
tests/redis_start.bats
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:start) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:start"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:start) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:start" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:start) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:start" l
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
26
tests/redis_stop.bats
Executable file
26
tests/redis_stop.bats
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:stop) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:stop"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:stop) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:stop" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:stop) success" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:stop" l
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
28
tests/redis_unexpose.bats
Executable file
28
tests/redis_unexpose.bats
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unexpose) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unexpose"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unexpose) error when service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unexpose" not_existing_service
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unexpose) success" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:expose" l
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unexpose" l
|
||||||
|
[[ ! -f $PLUGIN_DATA_ROOT/PORT ]]
|
||||||
|
assert_contains "${lines[*]}" "Service l unexposed"
|
||||||
|
}
|
||||||
|
|
||||||
39
tests/redis_unlink.bats
Executable file
39
tests/redis_unlink.bats
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
dokku apps:create my_app >&2
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
||||||
|
rm "$DOKKU_ROOT/my_app" -rf
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when there are no arguments" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unlink"
|
||||||
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when the app argument is missing" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l
|
||||||
|
assert_contains "${lines[*]}" "Please specify an app to run the command on"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when the app does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l not_existing_app
|
||||||
|
assert_contains "${lines[*]}" "App not_existing_app does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when the service does not exist" {
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" not_existing_service my_app
|
||||||
|
assert_contains "${lines[*]}" "Redis service not_existing_service does not exist"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "($PLUGIN_COMMAND_PREFIX:unlink) success" {
|
||||||
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2
|
||||||
|
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||||
|
links=$(cat "$PLUGIN_DATA_ROOT/l/LINKS")
|
||||||
|
assert_equal "$links" ""
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env bats
|
|
||||||
load test_helper
|
|
||||||
|
|
||||||
@test "(service) dokku" {
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:create l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:info l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:stop l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:stop l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:expose l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:restart l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku $PLUGIN_COMMAND_PREFIX:info l
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
dokku --force $PLUGIN_COMMAND_PREFIX:destroy l
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,8 @@ export PLUGIN_COMMAND_PREFIX="redis"
|
|||||||
export PLUGIN_PATH="$DOKKU_ROOT/plugins"
|
export PLUGIN_PATH="$DOKKU_ROOT/plugins"
|
||||||
export PLUGIN_DATA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
export PLUGIN_DATA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
||||||
|
|
||||||
mkdir -p $PLUGIN_DATA_ROOT
|
mkdir -p "$PLUGIN_DATA_ROOT"
|
||||||
|
rm -rf "${PLUGIN_DATA_ROOT:?}"/*
|
||||||
|
|
||||||
flunk() {
|
flunk() {
|
||||||
{ if [ "$#" -eq 0 ]; then cat -
|
{ if [ "$#" -eq 0 ]; then cat -
|
||||||
|
|||||||
Reference in New Issue
Block a user