1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-12-29 12:32:44 +00:00
hosts/test/help.bats
William Melody 187222614a Use braces in all variable references.
Braces are only required in certain cases, but the cognitive overhead in
keeping track of which cases require braces can be reduced by simply
always using them.

Example: `${NAME}`

Retain more widely-used braces `$NAME` convention in documentation.
2016-02-23 18:14:21 -08:00

49 lines
1.0 KiB
Bash

#!/usr/bin/env bats
load test_helper
_HELP_HEADER="$(
cat <<HEREDOC
__ __
/ /_ ____ _____/ /______
/ __ \/ __ \/ ___/ __/ ___/
/ / / / /_/ (__ ) /_(__ )
/_/ /_/\____/____/\__/____/
HEREDOC
)"
export _HELP_HEADER
@test "\`help\` with no arguments exits with status 0." {
run "${_HOSTS}" help
[ "${status}" -eq 0 ]
}
@test "\`help\` with no arguments prints default help." {
run "${_HOSTS}" help
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "${_HELP_HEADER}" ]]
}
@test "\`hosts -h\` prints default help." {
run "${_HOSTS}" -h
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "${_HELP_HEADER}" ]]
}
@test "\`hosts --help\` prints default help." {
run "${_HOSTS}" --help
[[ $(IFS=$'\n'; echo "${lines[*]:0:5}") == "${_HELP_HEADER}" ]]
}
@test "\`hosts help help\` prints \`help\` subcommand usage." {
run "${_HOSTS}" help help
_expected="$(
cat <<HEREDOC
Usage:
hosts help [<command>]
Description:
Display help information for hosts or a specified command.
HEREDOC
)"
[[ "${output}" == "${_expected}" ]]
}