这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/apps/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
}
}
}
4 changes: 2 additions & 2 deletions tests/apps/gitsubmodules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
},
"engines": {
"node": "0.10.x",
"npm": "1.3.x"
"npm": "2.7.x"
}
}
}
4 changes: 2 additions & 2 deletions tests/apps/nodejs-express-noprocfile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
},
"scripts": {
"start": "node web.js"
Expand Down
6 changes: 3 additions & 3 deletions tests/apps/nodejs-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"express": "2.5.x"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
"node": "0.10.x",
"npm": "2.7.x"
}
}
}
22 changes: 12 additions & 10 deletions tests/unit/apps.bats
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

load test_helper

APP=lifecycle-app

@test "apps:create" {
run dokku apps:create $APP
@test "(apps) apps" {
create_app
run bash -c "dokku apps | grep $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
assert_output $TEST_APP
destroy_app
}

@test "apps" {
run bash -c "dokku apps | grep $APP"
@test "(apps) apps:create" {
run dokku apps:create $TEST_APP
echo "output: "$output
echo "status: "$status
assert_output $APP
assert_success
destroy_app
}

@test "apps:destroy" {
run bash -c "dokku --force apps:destroy $APP"
@test "(apps) apps:destroy" {
create_app
run bash -c "dokku --force apps:destroy $TEST_APP"
echo "output: "$output
echo "status: "$status
assert_success
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/backup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# destroy_app
# }

# @test "backup:export" {
# @test "(backup) backup:export" {
# run dokku backup:export $backup_file
# echo "output: "$output
# echo "status: "$status
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/build-env.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ teardown() {
destroy_app
}

@test "build-env with special chars" {
@test "(build-env) special characters" {
run dokku config:set $TEST_APP NEWRELIC_APP_NAME="$TEST_APP (Staging)"
echo "output: "$output
echo "status: "$status
Expand Down
36 changes: 0 additions & 36 deletions tests/unit/cleanup.bats

This file was deleted.

26 changes: 13 additions & 13 deletions tests/unit/client.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ teardown() {
unset DOKKU_HOST
}

@test "dokku client (unconfigured DOKKU_HOST)" {
@test "(client) unconfigured DOKKU_HOST" {
unset DOKKU_HOST
run ./contrib/dokku_client.sh apps
echo "output: "$output
echo "status: "$status
assert_exit_status 20
}

@test "dokku client (no args should print help)" {
@test "(client) no args should print help" {
run /bin/bash -c "./contrib/dokku_client.sh | head -1 | egrep -q '^Usage: dokku \[.+\] COMMAND <app>.*'"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "dokku client (apps:create AND apps:destroy)" {
@test "(client) apps:create AND apps:destroy" {
setup_client_repo
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:create"
echo "output: "$output
Expand All @@ -39,7 +39,7 @@ teardown() {
assert_success
}

@test "dokku client (config:set)" {
@test "(client) config:set" {
run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
Expand All @@ -50,7 +50,7 @@ teardown() {
assert_success
}

@test "dokku client (config:unset)" {
@test "(client) config:unset" {
run ./contrib/dokku_client.sh config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
Expand All @@ -69,14 +69,14 @@ teardown() {
assert_failure
}

@test "dokku client (domains)" {
@test "(client) domains" {
run bash -c "./contrib/dokku_client.sh domains $TEST_APP | grep -q ${TEST_APP}.dokku.me"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "dokku client (domains:add)" {
@test "(client) domains:add" {
run ./contrib/dokku_client.sh domains:add $TEST_APP www.test.app.dokku.me
echo "output: "$output
echo "status: "$status
Expand All @@ -87,7 +87,7 @@ teardown() {
assert_success
}

@test "dokku client (domains:remove)" {
@test "(client) domains:remove" {
run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status
Expand All @@ -98,7 +98,7 @@ teardown() {
refute_line "test.app.dokku.me"
}

@test "dokku client (domains:clear)" {
@test "(client) domains:clear" {
run ./contrib/dokku_client.sh domains:add $TEST_APP test.app.dokku.me
echo "output: "$output
echo "status: "$status
Expand All @@ -109,7 +109,7 @@ teardown() {
assert_success
}

# @test "dokku client (ps)" {
# @test "(client) ps" {
# # CI support: 'Ah. I just spoke with our Docker expert --
# # looks like docker exec is built to work with docker-under-libcontainer,
# # but we're using docker-under-lxc. I don't have an estimated time for the fix, sorry
Expand All @@ -121,7 +121,7 @@ teardown() {
# assert_success
# }

@test "dokku client (ps:start)" {
@test "(client) ps:start" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP"
echo "output: "$output
Expand All @@ -137,7 +137,7 @@ teardown() {
assert_success
}

@test "dokku client (ps:stop)" {
@test "(client) ps:stop" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:stop $TEST_APP"
echo "output: "$output
Expand All @@ -149,7 +149,7 @@ teardown() {
assert_failure
}

@test "dokku client (ps:restart)" {
@test "(client) ps:restart" {
deploy_app
run bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh ps:restart $TEST_APP"
echo "output: "$output
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/config.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ teardown() {
rm -f "$DOKKU_ROOT/ENV"
}

@test "config:set" {
@test "(config) config:set" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "config:get" {
@test "(config) config:get" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
Expand All @@ -30,7 +30,7 @@ teardown() {
assert_output 'hello world'
}

@test "config:unset" {
@test "(config) config:unset" {
run ssh dokku@dokku.me config:set $TEST_APP test_var=true test_var2=\"hello world\"
echo "output: "$output
echo "status: "$status
Expand All @@ -49,15 +49,15 @@ teardown() {
assert_output ""
}

@test "global config (buildstep)" {
@test "(config) global config (buildstep)" {
deploy_app
run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "global config (dockerfile)" {
@test "(config) global config (dockerfile)" {
deploy_app dockerfile
run bash -c "dokku run $TEST_APP env | egrep '^global_test=true'"
echo "output: "$output
Expand Down
50 changes: 44 additions & 6 deletions tests/unit/00_dokku-standard.bats → tests/unit/core.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,76 @@ build_nginx_config() {
dokku nginx:build-config $TEST_APP
}

@test "run (with tty)" {
@test "(core) remove exited containers" {
deploy_app
# make sure we have many exited containers of the same 'type'
run bash -c "for cnt in 1 2 3; do dokku run $TEST_APP hostname; done"
echo "output: "$output
echo "status: "$status
assert_success
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_success
run dokku cleanup
echo "output: "$output
echo "status: "$status
assert_success
sleep 5 # wait for dokku cleanup to happen in the background
run bash -c "docker ps -a -f 'status=exited' --no-trunc=false | grep '/exec hostname'"
echo "output: "$output
echo "status: "$status
assert_failure
run bash -c "docker ps -a -f 'status=exited' -q --no-trunc=false"
echo "output: "$output
echo "status: "$status
assert_output ""
}

@test "(core) run (with tty)" {
deploy_app
run /bin/bash -c "dokku run $TEST_APP ls /app/package.json"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "run (without tty)" {
@test "(core) run (without tty)" {
deploy_app
run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "run (with --options)" {
@test "(core) run (with --options)" {
deploy_app
run /bin/bash -c "dokku --force --quiet run $TEST_APP node --version"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "urls (non-ssl)" {
@test "(core) unknown command" {
run /bin/bash -c "dokku fakecommand"
echo "output: "$output
echo "status: "$status
assert_failure
run /bin/bash -c "dokku fakecommand | grep -q 'is not a dokku command'"
echo "output: "$output
echo "status: "$status
assert_success
}

@test "(core) urls (non-ssl)" {
assert_urls "http://dokku.me"
build_nginx_config
assert_urls "http://${TEST_APP}.dokku.me"
add_domain "test.dokku.me"
assert_urls "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
}

@test "urls (app ssl)" {
@test "(core) urls (app ssl)" {
setup_test_tls
assert_urls "https://dokku.me"
build_nginx_config
Expand All @@ -67,7 +104,7 @@ build_nginx_config() {
assert_urls "https://node-js-app.dokku.me" "http://${TEST_APP}.dokku.me" "http://test.dokku.me"
}

@test "urls (wildcard ssl)" {
@test "(core) urls (wildcard ssl)" {
setup_test_tls_wildcard
assert_urls "https://dokku.me"
build_nginx_config
Expand All @@ -77,3 +114,4 @@ build_nginx_config() {
add_domain "dokku.example.com"
assert_urls "https://${TEST_APP}.dokku.me" "https://test.dokku.me" "http://dokku.example.com"
}

Loading