From 123fbea7c0e94d87a7e7256ccb372e277b6d675d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 11 Feb 2021 07:16:54 -0500 Subject: [PATCH] feat: add a deployment task test for cnb --- tests/apps/python/Procfile | 2 +- tests/apps/python/release.py | 10 ++++++++++ tests/apps/python/requirements.txt | 1 + tests/unit/app-json.bats | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/apps/python/release.py create mode 100644 tests/apps/python/requirements.txt diff --git a/tests/apps/python/Procfile b/tests/apps/python/Procfile index def474954..88d4d849f 100644 --- a/tests/apps/python/Procfile +++ b/tests/apps/python/Procfile @@ -7,7 +7,7 @@ cron: python3 worker.py web: python3 web.py # testing inline comment worker: python3 worker.py custom: echo -n -release: touch /app/release.test +release: python3 release.py # Old version with separate processes (use this if you have issues with the threaded version) diff --git a/tests/apps/python/release.py b/tests/apps/python/release.py new file mode 100644 index 000000000..afa731b5f --- /dev/null +++ b/tests/apps/python/release.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os + + +def main(): + print("SECRET_KEY: {0}".format(os.getenv('SECRET_KEY'))) + + +if __name__ == '__main__': + main() diff --git a/tests/apps/python/requirements.txt b/tests/apps/python/requirements.txt new file mode 100644 index 000000000..7e1060246 --- /dev/null +++ b/tests/apps/python/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/tests/unit/app-json.bats b/tests/unit/app-json.bats index 3851afe98..d8c86f832 100644 --- a/tests/unit/app-json.bats +++ b/tests/unit/app-json.bats @@ -103,3 +103,23 @@ teardown() { echo "status: $status" assert_success } + +@test "(app-json) app.json cnb release" { + run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_CNB_EXPERIMENTAL=1 SECRET_KEY=fjdkslafjdk" + echo "output: $output" + echo "status: $status" + assert_success + + run deploy_app python dokku@dokku.me:$TEST_APP add_requirements_txt + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "Executing release task from Procfile" + assert_output_contains "SECRET_KEY: fjdkslafjdk" + + run /bin/bash -c "curl $(dokku url $TEST_APP)/env" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains '"SECRET_KEY": "fjdkslafjdk"' +}