2016-01-27 02:31:17 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
# `hosts disabled` #############################################################
|
|
|
|
|
|
|
|
@test "\`disabled\` with no arguments exits with status 0." {
|
|
|
|
{
|
2016-02-24 02:14:21 +00:00
|
|
|
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
|
2016-01-27 02:31:17 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" disabled
|
2018-04-15 21:55:26 +00:00
|
|
|
printf "\${status}: %s\\n" "${status}"
|
|
|
|
printf "\${output}: '%s'\\n" "${output}"
|
2016-02-24 02:14:21 +00:00
|
|
|
[[ ${status} -eq 0 ]]
|
2016-01-27 02:31:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "\`disabled\` with no arguments prints list of disabled records." {
|
|
|
|
{
|
2016-02-24 02:14:21 +00:00
|
|
|
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
|
2016-01-27 02:31:17 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" disabled
|
2018-04-15 21:55:26 +00:00
|
|
|
printf "\${status}: %s\\n" "${status}"
|
|
|
|
printf "\${output}: '%s'\\n" "${output}"
|
2016-01-27 02:31:17 +00:00
|
|
|
[[ "${lines[0]}" == "0.0.0.0 example.com" ]]
|
|
|
|
[[ "${lines[1]}" == "127.0.0.1 example.com" ]]
|
|
|
|
[[ "${lines[2]}" == "" ]]
|
|
|
|
}
|
2016-01-27 03:03:08 +00:00
|
|
|
|
|
|
|
# help ########################################################################
|
|
|
|
|
|
|
|
@test "\`help disabled\` exits with status 0." {
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" help disabled
|
|
|
|
[[ ${status} -eq 0 ]]
|
2016-01-27 03:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "\`help disabled\` prints help information." {
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" help disabled
|
2018-04-15 21:55:26 +00:00
|
|
|
printf "\${status}: %s\\n" "${status}"
|
|
|
|
printf "\${output}: '%s'\\n" "${output}"
|
2016-01-27 03:03:08 +00:00
|
|
|
[[ "${lines[0]}" == "Usage:" ]]
|
|
|
|
[[ "${lines[1]}" == " hosts disabled" ]]
|
|
|
|
}
|