mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-24 21:57:35 +00:00
80edd464b6
Backslash is literal, so explicitly escape it rather than rely on fallback behavior. ShellCheck SC1117 https://github.com/koalaman/shellcheck/wiki/SC1117
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
# `hosts disabled` #############################################################
|
|
|
|
@test "\`disabled\` with no arguments exits with status 0." {
|
|
{
|
|
run "${_HOSTS}" add 0.0.0.0 example.com
|
|
run "${_HOSTS}" add 0.0.0.0 example.net
|
|
run "${_HOSTS}" add 127.0.0.1 example.com
|
|
run "${_HOSTS}" disable example.com
|
|
}
|
|
|
|
run "${_HOSTS}" disabled
|
|
printf "\${status}: %s\\n" "${status}"
|
|
printf "\${output}: '%s'\\n" "${output}"
|
|
[[ ${status} -eq 0 ]]
|
|
}
|
|
|
|
@test "\`disabled\` with no arguments prints list of disabled records." {
|
|
{
|
|
run "${_HOSTS}" add 0.0.0.0 example.com
|
|
run "${_HOSTS}" add 0.0.0.0 example.net
|
|
run "${_HOSTS}" add 127.0.0.1 example.com
|
|
run "${_HOSTS}" disable example.com
|
|
}
|
|
|
|
run "${_HOSTS}" disabled
|
|
printf "\${status}: %s\\n" "${status}"
|
|
printf "\${output}: '%s'\\n" "${output}"
|
|
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
|
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
|
[[ "${lines[2]}" == "" ]]
|
|
}
|
|
|
|
# help ########################################################################
|
|
|
|
@test "\`help disabled\` exits with status 0." {
|
|
run "${_HOSTS}" help disabled
|
|
[[ ${status} -eq 0 ]]
|
|
}
|
|
|
|
@test "\`help disabled\` prints help information." {
|
|
run "${_HOSTS}" help disabled
|
|
printf "\${status}: %s\\n" "${status}"
|
|
printf "\${output}: '%s'\\n" "${output}"
|
|
[[ "${lines[0]}" == "Usage:" ]]
|
|
[[ "${lines[1]}" == " hosts disabled" ]]
|
|
}
|