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