Skip to content

Commit

Permalink
chore: make all the service names used in the service_link tests the …
Browse files Browse the repository at this point in the history
…same
  • Loading branch information
Jose Diaz-Gonzalez committed Feb 21, 2023
1 parent 845af4f commit 998ff17
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions tests/service_link.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
load test_helper

setup() {
dokku "$PLUGIN_COMMAND_PREFIX:create" l
dokku "$PLUGIN_COMMAND_PREFIX:create" m
dokku "$PLUGIN_COMMAND_PREFIX:create" ls
dokku "$PLUGIN_COMMAND_PREFIX:create" ms
dokku apps:create my-app
}

teardown() {
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" m
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ms
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" ls
dokku --force apps:destroy my-app
}

Expand All @@ -22,15 +22,15 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:link) error when the app argument is missing" {
run dokku "$PLUGIN_COMMAND_PREFIX:link" l
run dokku "$PLUGIN_COMMAND_PREFIX:link" ls
echo "output: $output"
echo "status: $status"
assert_contains "${lines[*]}" "Please specify an app to run the command on"
assert_failure
}

@test "($PLUGIN_COMMAND_PREFIX:link) error when the app does not exist" {
run dokku "$PLUGIN_COMMAND_PREFIX:link" l not_existing_app
run dokku "$PLUGIN_COMMAND_PREFIX:link" ls not_existing_app
echo "output: $output"
echo "status: $status"
assert_contains "${lines[*]}" "App not_existing_app does not exist"
Expand All @@ -46,73 +46,73 @@ teardown() {
}

@test "($PLUGIN_COMMAND_PREFIX:link) error when the service is already linked to app" {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
echo "output: $output"
echo "status: $status"
assert_contains "${lines[*]}" "Already linked as DATABASE_URL"
assert_failure

dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) exports DATABASE_URL to app" {
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
run dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
echo "output: $output"
echo "status: $status"
url=$(dokku config:get my-app DATABASE_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "mysql://mariadb:$password@dokku-mariadb-l:3306/l"
password="$(sudo cat "$PLUGIN_DATA_ROOT/ls/PASSWORD")"
assert_contains "$url" "mysql://mariadb:$password@dokku-mariadb-ls:3306/ls"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) generates an alternate config url when DATABASE_URL already in use" {
dokku config:set my-app DATABASE_URL=mysql://user:pass@host:3306/db
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
run dokku config my-app
assert_contains "${lines[*]}" "DOKKU_MARIADB_AQUA_URL"
assert_success

dokku "$PLUGIN_COMMAND_PREFIX:link" m my-app
dokku "$PLUGIN_COMMAND_PREFIX:link" ms my-app
run dokku config my-app
assert_contains "${lines[*]}" "DOKKU_MARIADB_BLACK_URL"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" m my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ms my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) links to app with docker-options" {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
run dokku docker-options:report my-app
assert_contains "${lines[*]}" "--link dokku.mariadb.l:dokku-mariadb-l"
assert_contains "${lines[*]}" "--link dokku.mariadb.ls:dokku-mariadb-ls"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) uses apps MARIADB_DATABASE_SCHEME variable" {
dokku config:set my-app MARIADB_DATABASE_SCHEME=mariadb2
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app
url=$(dokku config:get my-app DATABASE_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "mariadb2://mariadb:$password@dokku-mariadb-l:3306/l"
password="$(sudo cat "$PLUGIN_DATA_ROOT/ls/PASSWORD")"
assert_contains "$url" "mariadb2://mariadb:$password@dokku-mariadb-ls:3306/ls"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) adds a querystring" {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --querystring "pool=5"
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app --querystring "pool=5"
url=$(dokku config:get my-app DATABASE_URL)
assert_contains "$url" "?pool=5"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

@test "($PLUGIN_COMMAND_PREFIX:link) uses a specified config url when alias is specified" {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --alias "ALIAS"
dokku "$PLUGIN_COMMAND_PREFIX:link" ls my-app --alias "ALIAS"
url=$(dokku config:get my-app ALIAS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "mysql://mariadb:$password@dokku-mariadb-l:3306/l"
password="$(sudo cat "$PLUGIN_DATA_ROOT/ls/PASSWORD")"
assert_contains "$url" "mysql://mariadb:$password@dokku-mariadb-ls:3306/ls"
assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
dokku "$PLUGIN_COMMAND_PREFIX:unlink" ls my-app
}

0 comments on commit 998ff17

Please sign in to comment.