From dffa8578d91601efe4e632929da8e697db084460 Mon Sep 17 00:00:00 2001 From: Tim Kimber Date: Fri, 7 Jan 2022 16:55:26 +0000 Subject: [PATCH] Add usage tests (test #722 fix) --- test/0-test-usage.bats | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/0-test-usage.bats diff --git a/test/0-test-usage.bats b/test/0-test-usage.bats new file mode 100644 index 0000000..5afb566 --- /dev/null +++ b/test/0-test-usage.bats @@ -0,0 +1,46 @@ +#! /usr/bin/env bats + +load '/bats-support/load.bash' +load '/bats-assert/load.bash' +load '/getssl/test/test_helper.bash' + + +# This is run for every test +teardown() { + [ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_RUN_TMPDIR/failed.skip +} + +setup() { + [ ! -f $BATS_RUN_TMPDIR/failed.skip ] || skip "skipping tests after first failure" + #export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt +} + + +@test "Run getssl without any arguments to verify the usage message is shown" { + if [ -n "$STAGING" ]; then + skip "Using staging server, skipping internal test" + fi + run ${CODE_DIR}/getssl + assert_line --partial "Usage: getssl" + assert_success +} + + +@test "Run getssl with --nocheck and verify the usage message is shown" { + if [ -n "$STAGING" ]; then + skip "Using staging server, skipping internal test" + fi + run ${CODE_DIR}/getssl --nocheck + assert_line --partial "Usage: getssl" + assert_success +} + + +@test "Run getssl with --upgrade and verify the usage message is NOT shown" { + if [ -n "$STAGING" ]; then + skip "Using staging server, skipping internal test" + fi + run ${CODE_DIR}/getssl --upgrade + refute_output + assert_success +}