From 592b10122d652fee0c4e04e87b9fed6d390d55bf Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Thu, 3 Oct 2019 17:48:20 -0400 Subject: [PATCH] Add test of DOKKU_SCALE update --- tests/unit/10_ps-general.bats | 25 +++++++++++++++++++++++++ tests/unit/test_helper.bash | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/unit/10_ps-general.bats b/tests/unit/10_ps-general.bats index fe585de35..86d3a08c7 100644 --- a/tests/unit/10_ps-general.bats +++ b/tests/unit/10_ps-general.bats @@ -41,6 +41,31 @@ EOF assert_output "node worker.js" } +@test "(ps:scale) update DOKKU_SCALE from Procfile" { + local TMP=$(mktemp -d "/tmp/dokku.me.XXXXX") + trap 'popd &>/dev/null || true; rm -rf "$TMP"' INT TERM + + CUSTOM_TMP="$TMP" deploy_app nodejs-express + + run /bin/bash -c "dokku --quiet ps:scale $TEST_APP" + output=$(echo "$output" | tr -s " ") + echo "output: ($output)" + assert_output $'cron: 0 \ncustom: 0 \nrelease: 0 \nweb: 1 \nworker: 0 ' + + pushd $TMP + echo scaletest: sleep infinity >> Procfile + git commit Procfile -m 'Add scaletest process' + git push target master:master + + run /bin/bash -c "dokku --quiet ps:scale $TEST_APP" + output=$(echo "$output" | tr -s " ") + echo "output: ($output)" + assert_output $'cron: 0 \ncustom: 0 \nrelease: 0 \nweb: 1 \nworker: 0 \nscaletest: 0 ' + + popd + rm -rf "$TMP" +} + @test "(ps:restart-policy) default policy" { run /bin/bash -c "dokku --quiet ps:restart-policy $TEST_APP" echo "output: $output" diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 5b79d3426..7381ed9d1 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -222,7 +222,7 @@ deploy_app() { local APP_TYPE=${APP_TYPE:="nodejs-express"} local GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"} local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"} - local TMP=$(mktemp -d "/tmp/dokku.me.XXXXX") + local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")} rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP" @@ -230,7 +230,7 @@ deploy_app() { [[ -n "$CUSTOM_TEMPLATE" ]] && $CUSTOM_TEMPLATE $TEST_APP $TMP/$CUSTOM_PATH pushd "$TMP" &>/dev/null || exit 1 - trap 'popd &>/dev/null || true; rm -rf "$TMP"' RETURN INT TERM + [[ -z "$CUSTOM_TMP" ]] && trap 'popd &>/dev/null || true; rm -rf "$TMP"' RETURN INT TERM git init git config user.email "robot@example.com"