#!/bin/bash # Tests for main entrypoint this_dir="$(cd "$(dirname "$0")" && pwd)" source "${this_dir}/common.sh" test_main_help() { local output output="$(szecret --help)" assert_contains "${output}" "szecret" "help output" assert_contains "${output}" "Usage" "help output" pass "main --help shows usage" } test_main_help_short() { local output output="$(szecret -h)" assert_contains "${output}" "szecret" "help output" pass "main -h shows usage" } test_main_unknown_command() { assert_failure szecret nonexistent-command pass "main fails on unknown command" } test_main_no_command() { assert_failure szecret pass "main fails without command" } test_main_dispatches_to_command() { echo "dispatch-test-value" | szecret put "dispatch-test" local retrieved retrieved="$(szecret get "dispatch-test")" assert_equals "dispatch-test-value" "${retrieved}" "dispatched command" pass "main dispatches to commands" } test_command_help() { local output output="$(szecret get --help)" assert_contains "${output}" "get" "command help" assert_contains "${output}" "Usage" "command help" pass "command --help shows command usage" } run_tests() { test_main_help test_main_help_short test_main_unknown_command test_main_no_command test_main_dispatches_to_command test_command_help } [[ "${BASH_SOURCE[0]}" == "${0}" ]] && run_tests