From 4a60497d3eae7a3dc4a1bf42a1e18d53cd32a2b8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 10 Feb 2020 01:56:50 -0500 Subject: [PATCH] feat: add tests for all help commands --- plugins/20_events/help-functions | 2 +- tests/unit/10_apps.bats | 14 ++++++++++++++ tests/unit/10_certs.bats | 14 ++++++++++++++ tests/unit/10_checks.bats | 14 ++++++++++++++ tests/unit/10_git.bats | 14 ++++++++++++++ tests/unit/10_ps-general.bats | 14 ++++++++++++++ tests/unit/10_repo.bats | 14 ++++++++++++++ tests/unit/10_tar.bats | 14 ++++++++++++++ tests/unit/20_config.bats | 14 ++++++++++++++ tests/unit/20_docker-options.bats | 14 ++++++++++++++ tests/unit/20_domains.bats | 14 ++++++++++++++ tests/unit/20_network.bats | 14 ++++++++++++++ tests/unit/20_nginx-vhosts_1.bats | 14 ++++++++++++++ tests/unit/20_resource.bats | 14 ++++++++++++++ tests/unit/20_storage.bats | 14 ++++++++++++++ tests/unit/30_events.bats | 14 ++++++++++++++ tests/unit/30_scheduler-docker-local.bats | 14 ++++++++++++++ tests/unit/30_ssh_keys.bats | 14 ++++++++++++++ tests/unit/40_plugin.bats | 14 ++++++++++++++ tests/unit/40_proxy.bats | 14 ++++++++++++++ tests/unit/40_tags.bats | 14 ++++++++++++++ tests/unit/40_trace.bats | 14 ++++++++++++++ 22 files changed, 295 insertions(+), 1 deletion(-) diff --git a/plugins/20_events/help-functions b/plugins/20_events/help-functions index f80c45058..610242ada 100755 --- a/plugins/20_events/help-functions +++ b/plugins/20_events/help-functions @@ -6,7 +6,7 @@ cmd-events-help() { declare desc="help command" declare CMD="$1" local plugin_name="events" - local plugin_description="Interact with Dokku event logger" + local plugin_description="Manage event logging" if [[ "$CMD" == "$plugin_name:help" ]]; then echo -e "Usage: dokku $plugin_name[:COMMAND]" diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index ccb4bbf44..0c3464224 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -10,6 +10,20 @@ teardown() { global_teardown } +@test "(apps) apps:help" { + run /bin/bash -c "dokku apps" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage apps" + help_output="$output" + + run /bin/bash -c "dokku apps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage apps" + assert_output "$help_output" +} + @test "(apps) apps:create" { run /bin/bash -c "dokku apps:create $TEST_APP" echo "output: $output" diff --git a/tests/unit/10_certs.bats b/tests/unit/10_certs.bats index 4335ff832..bfe677dd4 100644 --- a/tests/unit/10_certs.bats +++ b/tests/unit/10_certs.bats @@ -27,6 +27,20 @@ teardown() { global_teardown } +@test "(certs) certs:help" { + run /bin/bash -c "dokku certs" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage SSL (TLS) certs" + help_output="$output" + + run /bin/bash -c "dokku certs:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage SSL (TLS) certs" + assert_output "$help_output" +} + @test "(certs) certs:add" { run /bin/bash -c "dokku certs:add $TEST_APP $BATS_TMPDIR/tls/server.crt $BATS_TMPDIR/tls/server.key" echo "output: $output" diff --git a/tests/unit/10_checks.bats b/tests/unit/10_checks.bats index 51c055e03..e8ba665fb 100644 --- a/tests/unit/10_checks.bats +++ b/tests/unit/10_checks.bats @@ -16,6 +16,20 @@ teardown() { global_teardown } +@test "(checks) checks:help" { + run /bin/bash -c "dokku checks" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage zero-downtime settings" + help_output="$output" + + run /bin/bash -c "dokku checks:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage zero-downtime settings" + assert_output "$help_output" +} + @test "(checks) checks" { run /bin/bash -c "dokku checks $TEST_APP 2>/dev/null | grep $TEST_APP | xargs" echo "output: $output" diff --git a/tests/unit/10_git.bats b/tests/unit/10_git.bats index 9a7449911..d258b4c01 100644 --- a/tests/unit/10_git.bats +++ b/tests/unit/10_git.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(git) git:help" { + run /bin/bash -c "dokku git" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + help_output="$output" + + run /bin/bash -c "dokku git:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via git" + assert_output "$help_output" +} + @test "(git) deploy specific branch" { run /bin/bash -c "dokku git:set --global deploy-branch global-branch" echo "output: $output" diff --git a/tests/unit/10_ps-general.bats b/tests/unit/10_ps-general.bats index 86d3a08c7..4b2fc7220 100644 --- a/tests/unit/10_ps-general.bats +++ b/tests/unit/10_ps-general.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(ps) ps:help" { + run /bin/bash -c "dokku ps" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage container processes" + help_output="$output" + + run /bin/bash -c "dokku ps:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage container processes" + assert_output "$help_output" +} + @test "(ps) ps:inspect" { dokku config:set "$TEST_APP" key=value key=value=value deploy_app dockerfile diff --git a/tests/unit/10_repo.bats b/tests/unit/10_repo.bats index 79e2805e9..9df856052 100644 --- a/tests/unit/10_repo.bats +++ b/tests/unit/10_repo.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(repo) repo:help" { + run /bin/bash -c "dokku repo" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the app's repo" + help_output="$output" + + run /bin/bash -c "dokku repo:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the app's repo" + assert_output "$help_output" +} + @test "(repo) repo:gc, repo:purge-cache" { run /bin/bash -c "dokku repo:gc $TEST_APP" echo "output: $output" diff --git a/tests/unit/10_tar.bats b/tests/unit/10_tar.bats index 3fe8204ca..7d0e3247c 100644 --- a/tests/unit/10_tar.bats +++ b/tests/unit/10_tar.bats @@ -25,6 +25,20 @@ deploy_app_tar() { sleep 5 # nginx needs some time to itself... } +@test "(tar) tar:help" { + run /bin/bash -c "dokku tar" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via tar" + help_output="$output" + + run /bin/bash -c "dokku tar:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage app deploys via tar" + assert_output "$help_output" +} + @test "(tar) non-tarbomb deploy using tar:in" { deploy_app_tar nodejs-express --transform 's,^,prefix/,' diff --git a/tests/unit/20_config.bats b/tests/unit/20_config.bats index 896729748..0ca7f73ba 100644 --- a/tests/unit/20_config.bats +++ b/tests/unit/20_config.bats @@ -18,6 +18,20 @@ teardown() { global_teardown } +@test "(config) config:help" { + run /bin/bash -c "dokku config" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage global and app-specific config vars" + help_output="$output" + + run /bin/bash -c "dokku config:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage global and app-specific config vars" + assert_output "$help_output" +} + @test "(config) config:set --global" { run ssh dokku@dokku.me config:set --global test_var=true test_var2=\"hello world\" test_var3='double\"quotes' echo "output: $output" diff --git a/tests/unit/20_docker-options.bats b/tests/unit/20_docker-options.bats index 76bc8c1d3..5744a647d 100644 --- a/tests/unit/20_docker-options.bats +++ b/tests/unit/20_docker-options.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(docker-options) docker-options:help" { + run /bin/bash -c "dokku docker-options" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker options for an app" + help_output="$output" + + run /bin/bash -c "dokku docker-options:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker options for an app" + assert_output "$help_output" +} + @test "(docker-options) docker-options:add (all phases)" { run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\"" echo "output: $output" diff --git a/tests/unit/20_domains.bats b/tests/unit/20_domains.bats index 1fee4f290..b0ff43e91 100644 --- a/tests/unit/20_domains.bats +++ b/tests/unit/20_domains.bats @@ -16,6 +16,20 @@ teardown() { global_teardown } +@test "(domains) domains:help" { + run /bin/bash -c "dokku domains" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage domains used by the proxy" + help_output="$output" + + run /bin/bash -c "dokku domains:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage domains used by the proxy" + assert_output "$help_output" +} + @test "(domains) domains" { dokku domains:setup $TEST_APP run /bin/bash -c "dokku domains $TEST_APP 2>/dev/null | grep ${TEST_APP}.dokku.me" diff --git a/tests/unit/20_network.bats b/tests/unit/20_network.bats index eb7278e56..13438ffaf 100644 --- a/tests/unit/20_network.bats +++ b/tests/unit/20_network.bats @@ -43,6 +43,20 @@ assert_external_port() { fi } +@test "(network) network:help" { + run /bin/bash -c "dokku network" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage network settings for an app" + help_output="$output" + + run /bin/bash -c "dokku network:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage network settings for an app" + assert_output "$help_output" +} + @test "(network) network:set bind-all-interfaces" { deploy_app assert_nonssl_domain "${TEST_APP}.dokku.me" diff --git a/tests/unit/20_nginx-vhosts_1.bats b/tests/unit/20_nginx-vhosts_1.bats index c63ab2764..216981c6e 100644 --- a/tests/unit/20_nginx-vhosts_1.bats +++ b/tests/unit/20_nginx-vhosts_1.bats @@ -17,6 +17,20 @@ teardown() { global_teardown } +@test "(nginx) nginx:help" { + run /bin/bash -c "dokku nginx" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the nginx proxy" + help_output="$output" + + run /bin/bash -c "dokku nginx:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the nginx proxy" + assert_output "$help_output" +} + @test "(nginx-vhosts) nginx:build-config (domains:disable/enable)" { deploy_app dokku domains:disable $TEST_APP diff --git a/tests/unit/20_resource.bats b/tests/unit/20_resource.bats index 31b2f53e5..4c2a13c4f 100644 --- a/tests/unit/20_resource.bats +++ b/tests/unit/20_resource.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(resource) resource:help" { + run /bin/bash -c "dokku resource" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage resource settings for an app" + help_output="$output" + + run /bin/bash -c "dokku resource:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage resource settings for an app" + assert_output "$help_output" +} + @test "(resource) resource:limit" { run /bin/bash -c "dokku resource:limit $TEST_APP" echo "output: $output" diff --git a/tests/unit/20_storage.bats b/tests/unit/20_storage.bats index 73890cab4..05244838a 100644 --- a/tests/unit/20_storage.bats +++ b/tests/unit/20_storage.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(storage) storage:help" { + run /bin/bash -c "dokku storage" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage mounted volumes" + help_output="$output" + + run /bin/bash -c "dokku storage:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage mounted volumes" + assert_output "$help_output" +} + @test "(storage) storage:mount, storage:list, storage:umount" { run /bin/bash -c "dokku storage:mount $TEST_APP /tmp/mount:/mount" echo "output: $output" diff --git a/tests/unit/30_events.bats b/tests/unit/30_events.bats index 520e1fefe..e12098ee2 100644 --- a/tests/unit/30_events.bats +++ b/tests/unit/30_events.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(events) events:help" { + run /bin/bash -c "dokku events" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage event logging" + help_output="$output" + + run /bin/bash -c "dokku events:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage event logging" + assert_output "$help_output" +} + @test "(events) check conffiles" { run /bin/bash -c "test -f /etc/logrotate.d/dokku" echo "output: $output" diff --git a/tests/unit/30_scheduler-docker-local.bats b/tests/unit/30_scheduler-docker-local.bats index 1a2b39336..a922b0428 100644 --- a/tests/unit/30_scheduler-docker-local.bats +++ b/tests/unit/30_scheduler-docker-local.bats @@ -10,6 +10,20 @@ teardown() { global_teardown } +@test "(scheduler-docker-local) scheduler-docker-local:help" { + run /bin/bash -c "dokku scheduler-docker-local" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the docker-local scheduler integration for an app" + help_output="$output" + + run /bin/bash -c "dokku scheduler-docker-local:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the docker-local scheduler integration for an app" + assert_output "$help_output" +} + @test "(scheduler-docker-local) timer installed" { run /bin/bash -c "systemctl list-timers | grep dokku-retire" echo "output: $output" diff --git a/tests/unit/30_ssh_keys.bats b/tests/unit/30_ssh_keys.bats index b14d9a06a..b714c7a27 100644 --- a/tests/unit/30_ssh_keys.bats +++ b/tests/unit/30_ssh_keys.bats @@ -36,6 +36,20 @@ teardown() { global_teardown } +@test "(ssh-keys) ssh-keys:help" { + run /bin/bash -c "dokku ssh-keys" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage public ssh keys used for deployment" + help_output="$output" + + run /bin/bash -c "dokku ssh-keys:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage public ssh keys used for deployment" + assert_output "$help_output" +} + @test "(ssh-keys) ssh-keys:add, ssh-keys:list, ssh-keys:remove" { run /bin/bash -c "dokku ssh-keys:add name1 /tmp/testkey.pub" echo "output: $output" diff --git a/tests/unit/40_plugin.bats b/tests/unit/40_plugin.bats index a2f94b51a..3dc8ffc3e 100644 --- a/tests/unit/40_plugin.bats +++ b/tests/unit/40_plugin.bats @@ -24,6 +24,20 @@ teardown() { global_teardown } +@test "(plugin) plugin:help" { + run /bin/bash -c "dokku plugin" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage installed plugins" + help_output="$output" + + run /bin/bash -c "dokku plugin:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage installed plugins" + assert_output "$help_output" +} + @test "(plugin) plugin:install, plugin:disable, plugin:update plugin:uninstall" { run /bin/bash -c "dokku plugin:install $TEST_PLUGIN_GIT_REPO --name $TEST_PLUGIN_NAME" echo "output: $output" diff --git a/tests/unit/40_proxy.bats b/tests/unit/40_proxy.bats index 3b53ee724..ec4ee319d 100644 --- a/tests/unit/40_proxy.bats +++ b/tests/unit/40_proxy.bats @@ -41,6 +41,20 @@ assert_external_port() { fi } +@test "(proxy) proxy:help" { + run /bin/bash -c "dokku proxy" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the proxy integration for an app" + help_output="$output" + + run /bin/bash -c "dokku proxy:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage the proxy integration for an app" + assert_output "$help_output" +} + @test "(proxy) proxy:enable/disable" { deploy_app assert_nonssl_domain "${TEST_APP}.dokku.me" diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index c5c5c89ea..cfa9a569d 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -12,6 +12,20 @@ teardown() { global_teardown } +@test "(tags) tags:help" { + run /bin/bash -c "dokku tags" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker image tags" + help_output="$output" + + run /bin/bash -c "dokku tags:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage docker image tags" + assert_output "$help_output" +} + @test "(tags) tags:create, tags, tags:destroy" { run /bin/bash -c "dokku tags:create $TEST_APP v0.9.0" echo "output: $output" diff --git a/tests/unit/40_trace.bats b/tests/unit/40_trace.bats index 5a16b139a..41bed414d 100644 --- a/tests/unit/40_trace.bats +++ b/tests/unit/40_trace.bats @@ -24,6 +24,20 @@ teardown() { assert_success } +@test "(trace) trace:help" { + run /bin/bash -c "dokku trace" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage trace mode" + help_output="$output" + + run /bin/bash -c "dokku trace:help" + echo "output: $output" + echo "status: $status" + assert_output_contains "Manage trace mode" + assert_output "$help_output" +} + @test "(trace) trace on" { run /bin/bash -c "dokku trace on" echo "output: $output"