2016-01-27 02:53:41 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
# `hosts enabled` #############################################################
|
|
|
|
|
|
|
|
@test "\`enabled\` 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.2 example.com
|
|
|
|
run "${_HOSTS}" disable 0.0.0.0
|
2016-01-27 02:53:41 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" enabled
|
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:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "\`enabled\` with no arguments prints list of enabled 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.2 example.com
|
|
|
|
run "${_HOSTS}" disable 0.0.0.0
|
2016-01-27 02:53:41 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" enabled
|
2018-04-15 21:55:26 +00:00
|
|
|
printf "\${status}: %s\\n" "${status}"
|
|
|
|
printf "\${output}: '%s'\\n" "${output}"
|
2020-04-08 23:43:07 +00:00
|
|
|
[[ "${lines[0]}" =~ 127.0.0.1[[:space:]]+localhost ]]
|
|
|
|
[[ "${lines[1]}" =~ 255.255.255.255[[:space:]]+broadcasthost ]]
|
|
|
|
[[ "${lines[2]}" =~ \:\:1[[:space:]]+localhost ]]
|
|
|
|
[[ "${lines[3]}" =~ fe80\:\:1\%lo0[[:space:]]+localhost ]]
|
|
|
|
[[ "${lines[4]}" =~ 127.0.0.2[[:space:]]+example.com ]]
|
2016-01-27 02:53:41 +00:00
|
|
|
}
|
2016-01-27 03:05:10 +00:00
|
|
|
|
|
|
|
# help ########################################################################
|
|
|
|
|
|
|
|
@test "\`help enabled\` exits with status 0." {
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" help enabled
|
|
|
|
[[ ${status} -eq 0 ]]
|
2016-01-27 03:05:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "\`help enabled\` prints help information." {
|
2016-02-24 02:14:21 +00:00
|
|
|
run "${_HOSTS}" help enabled
|
2018-04-15 21:55:26 +00:00
|
|
|
printf "\${status}: %s\\n" "${status}"
|
|
|
|
printf "\${output}: '%s'\\n" "${output}"
|
2016-01-27 03:05:10 +00:00
|
|
|
[[ "${lines[0]}" == "Usage:" ]]
|
|
|
|
[[ "${lines[1]}" == " hosts enabled" ]]
|
|
|
|
}
|