Skip to content

Commit

Permalink
tests: use a username longer than one character to workaround bug in …
Browse files Browse the repository at this point in the history
…upstream docker image

Refs apache/couchdb-docker#206
  • Loading branch information
josegonzalez committed Sep 12, 2021
1 parent 4e6d797 commit 4fdda22
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 136 deletions.
12 changes: 6 additions & 6 deletions tests/hook_pre_delete.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ load test_helper

setup() {
dokku apps:create my-app
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app >&2
}

teardown() {
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app >&2
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app >&2
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:hook:pre-delete) removes app from links file when destroying app" {
[[ -n $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]]
[[ -n $(< "$PLUGIN_DATA_ROOT/ls/LINKS") ]]
dokku --force apps:destroy my-app
[[ -z $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]]
[[ -z $(< "$PLUGIN_DATA_ROOT/ls/LINKS") ]]
}
12 changes: 6 additions & 6 deletions tests/service_clone.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:clone) error when there are no arguments" {
Expand All @@ -22,24 +22,24 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:clone) error when new service isn't provided" {
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l
run dokku "$PLUGIN_COMMAND_PREFIX:clone" ls
assert_contains "${lines[*]}" "Please specify a name for the new service"
assert_failure
}

@test "($PLUGIN_COMMAND_PREFIX:clone) error when new service already exists" {
dokku "$PLUGIN_COMMAND_PREFIX:create" new_service
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l new_service
run dokku "$PLUGIN_COMMAND_PREFIX:clone" ls new_service
assert_contains "${lines[*]}" "service new_service already exists"
assert_failure

dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" new_service
}

@test "($PLUGIN_COMMAND_PREFIX:clone) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:clone" l new_service
run dokku "$PLUGIN_COMMAND_PREFIX:clone" ls new_service
[[ -f $PLUGIN_DATA_ROOT/new_service/ID ]]
assert_contains "${lines[*]}" "Copying data from l to new_service"
assert_contains "${lines[*]}" "Copying data from ls to new_service"
assert_contains "${lines[*]}" "Done"
assert_success

Expand Down
6 changes: 3 additions & 3 deletions tests/service_create.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
load test_helper

@test "($PLUGIN_COMMAND_PREFIX:create) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:create" l
assert_contains "${lines[*]}" "container created: l"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
run dokku "$PLUGIN_COMMAND_PREFIX:create" ls
assert_contains "${lines[*]}" "container created: ls"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:create) service with dashes" {
Expand Down
18 changes: 9 additions & 9 deletions tests/service_destroy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
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"
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
assert_contains "${lines[*]}" "container deleted: ls"
}

@test "($PLUGIN_COMMAND_PREFIX:destroy) error when there are no arguments" {
Expand All @@ -18,13 +18,13 @@ load test_helper
}

@test "($PLUGIN_COMMAND_PREFIX:destroy) error when container is linked to an app" {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
dokku apps:create app
dokku "$PLUGIN_COMMAND_PREFIX:link" l app
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku "$PLUGIN_COMMAND_PREFIX:link" ls app
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
assert_contains "${lines[*]}" "Cannot delete linked service"

dokku "$PLUGIN_COMMAND_PREFIX:unlink" l app
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
assert_contains "${lines[*]}" "container deleted: l"
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls app
run dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
assert_contains "${lines[*]}" "container deleted: ls"
}
8 changes: 4 additions & 4 deletions tests/service_export.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:export) error when there are no arguments" {
Expand All @@ -24,15 +24,15 @@ teardown() {
skip "No tty is available on Github Actions"
fi
export SSH_TTY=`tty`
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
run dokku "$PLUGIN_COMMAND_PREFIX:export" ls
echo "output: $output"
echo "status: $status"
assert_exit_status 0
}

@test "($PLUGIN_COMMAND_PREFIX:export) success without SSH_TTY" {
unset SSH_TTY
run dokku "$PLUGIN_COMMAND_PREFIX:export" l
run dokku "$PLUGIN_COMMAND_PREFIX:export" ls
echo "output: $output"
echo "status: $status"
assert_exit_status 0
Expand Down
8 changes: 4 additions & 4 deletions tests/service_expose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:expose) error when there are no arguments" {
Expand All @@ -20,11 +20,11 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:expose) success when not providing custom ports" {
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls
[[ "${lines[*]}" =~ exposed\ on\ port\(s\)\ \[container\-\>host\]\:\ [[:digit:]]+ ]]
}

@test "($PLUGIN_COMMAND_PREFIX:expose) success when providing custom ports" {
run dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242
run dokku "$PLUGIN_COMMAND_PREFIX:expose" ls 4242
assert_contains "${lines[*]}" "exposed on port(s) [container->host]: 5984->4242"
}
8 changes: 4 additions & 4 deletions tests/service_import.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
echo '{"new_edits":false,"docs":[]}' | tee "/tmp/fake.json"
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
rm -f "/tmp/fake.json"
}

Expand All @@ -27,13 +27,13 @@ teardown() {
if [[ -n "$GITHUB_WORKFLOW" ]]; then
skip "No tty is available on Github Actions"
fi
run dokku "$PLUGIN_COMMAND_PREFIX:import" l
run dokku "$PLUGIN_COMMAND_PREFIX:import" ls
assert_contains "${lines[*]}" "No data provided on stdin"
assert_failure
}

@test "($PLUGIN_COMMAND_PREFIX:import) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:import" l < "/tmp/fake.json"
run dokku "$PLUGIN_COMMAND_PREFIX:import" ls < "/tmp/fake.json"
echo "output: $output"
echo "status: $status"
assert_success
Expand Down
40 changes: 20 additions & 20 deletions tests/service_info.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
}

@test "($PLUGIN_COMMAND_PREFIX:info) error when there are no arguments" {
Expand All @@ -20,9 +20,9 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:info) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l
local password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "http://l:$password@dokku-couchdb-l:5984/l"
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls
local password="$(sudo cat "$PLUGIN_DATA_ROOT/ls/PASSWORD")"
assert_contains "${lines[*]}" "http://ls:$password@dokku-couchdb-ls:5984/ls"
}

@test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" {
Expand All @@ -34,45 +34,45 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:info) success with flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
local password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_output "http://l:$password@dokku-couchdb-l:5984/l"
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --dsn
local password="$(sudo cat "$PLUGIN_DATA_ROOT/ls/PASSWORD")"
assert_output "http://ls:$password@dokku-couchdb-ls:5984/ls"

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --config-dir
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --data-dir
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --data-dir
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --dsn
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --exposed-ports
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --exposed-ports
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --id
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --id
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --internal-ip
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --internal-ip
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --links
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --links
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --service-root
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --service-root
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --service-root
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --service-root
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --status
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --status
assert_success

run dokku "$PLUGIN_COMMAND_PREFIX:info" l --version
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --version
assert_success
}

@test "($PLUGIN_COMMAND_PREFIX:info) error when invalid flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --invalid-flag
run dokku "$PLUGIN_COMMAND_PREFIX:info" ls --invalid-flag
assert_failure
}
Loading

0 comments on commit 4fdda22

Please sign in to comment.