mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-25 06:07:40 +00:00
2db235f68b
`\d` is not portable so use `[[:digit]]`.
41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
@test "\`hosts version\` returns with 0 status." {
|
|
run "${_HOSTS}" version
|
|
[[ "${status}" -eq 0 ]]
|
|
}
|
|
|
|
@test "\`hosts version\` prints a version number." {
|
|
run "${_HOSTS}" version
|
|
printf "'%s'" "${output}"
|
|
echo "${output}" | grep -q '[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+'
|
|
}
|
|
|
|
@test "\`hosts --version\` returns with 0 status." {
|
|
run "${_HOSTS}" --version
|
|
[[ "${status}" -eq 0 ]]
|
|
}
|
|
|
|
@test "\`hosts --version\` prints a version number." {
|
|
run "${_HOSTS}" --version
|
|
printf "'%s'" "${output}"
|
|
echo "${output}" | grep -q '[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+'
|
|
}
|
|
|
|
# help ########################################################################
|
|
|
|
@test "\`help version\` exits with status 0." {
|
|
run "${_HOSTS}" help version
|
|
[[ ${status} -eq 0 ]]
|
|
}
|
|
|
|
@test "\`help version\` prints help information." {
|
|
run "${_HOSTS}" help version
|
|
printf "\${status}: %s\\n" "${status}"
|
|
printf "\${output}: '%s'\\n" "${output}"
|
|
[[ "${lines[0]}" == "Usage:" ]]
|
|
[[ "${lines[1]}" == " hosts (version | --version)" ]]
|
|
}
|