domains plugin unit tests and fix for errant substring match

This commit is contained in:
Michael Hobbs
2014-12-21 13:52:20 -08:00
parent d1e94f6c91
commit 283432f214
2 changed files with 67 additions and 0 deletions

51
tests/unit/domains.bats Normal file
View File

@@ -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
}

View File

@@ -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
}