diff --git a/tests/unit/domains.bats b/tests/unit/domains.bats new file mode 100644 index 000000000..67b8cbb72 --- /dev/null +++ b/tests/unit/domains.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + deploy_app +} + +teardown() { + destroy_app +} + +@test "domains" { + run bash -c "dokku domains $TEST_APP | grep ${TEST_APP}.dokku.me" + echo "output: "$output + echo "status: "$status + assert_output "${TEST_APP}.dokku.me" +} + +@test "domains:add" { + run dokku domains:add $TEST_APP www.test.app.dokku.me + echo "output: "$output + echo "status: "$status + assert_success + run dokku domains:add $TEST_APP test.app.dokku.me + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "domains:remove" { + run dokku domains:add $TEST_APP test.app.dokku.me + echo "output: "$output + echo "status: "$status + assert_success + run dokku domains:remove $TEST_APP test.app.dokku.me + echo "output: "$output + echo "status: "$status + refute_line "test.app.dokku.me" +} + +@test "domains:clear" { + run dokku domains:add $TEST_APP test.app.dokku.me + echo "output: "$output + echo "status: "$status + assert_success + run dokku domains:clear $TEST_APP + echo "output: "$output + echo "status: "$status + assert_success +} diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 22bb07d29..7a1d6719f 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -1,4 +1,5 @@ #!/usr/bin/env bash + # constants TEST_APP=my-cool-guy-test-app @@ -85,3 +86,18 @@ create_app() { destroy_app() { echo $TEST_APP | dokku apps:destroy $TEST_APP } + +deploy_app() { + TMP=$(mktemp -d -t "$TARGET.XXXXX") + rmdir $TMP && cp -r ./tests/apps/config $TMP + cd $TMP + git init + git config user.email "robot@example.com" + git config user.name "Test Robot" + git remote add target dokku@dokku.me:$TEST_APP + + [[ -f gitignore ]] && mv gitignore .gitignore + git add . + git commit -m 'initial commit' + git push target master || destroy_app +}