diff --git a/test/list.bats b/test/list.bats index b7dd577..cfdd799 100644 --- a/test/list.bats +++ b/test/list.bats @@ -139,7 +139,7 @@ Disabled: [[ "${lines[2]}" == "" ]] } -@test "\`search \` prints records with matching comments." { +@test "\`list \` prints records with matching comments." { { run "${_HOSTS}" add 0.0.0.0 example.com run "${_HOSTS}" add 0.0.0.0 example.net "Example Comment" @@ -153,6 +153,24 @@ Disabled: [[ "${lines[2]}" == "" ]] } + +@test "\`list \` prints disabled records with matching comments." { + { + run "${_HOSTS}" add 0.0.0.0 example.com + run "${_HOSTS}" add 0.0.0.0 example.net "Example Comment" + run "${_HOSTS}" add 127.0.0.1 example.com + run "${_HOSTS}" add 127.0.0.1 example.biz "Example Comment" + run "${_HOSTS}" disable example.biz + } + + run "${_HOSTS}" list "Comment" + printf "\${status}: %s\\n" "${status}" + printf "\${output}: '%s'\\n" "${output}" + [[ "${lines[0]}" == "0.0.0.0 example.net # Example Comment" ]] + [[ "${lines[1]}" == "disabled: 127.0.0.1 example.biz # Example Comment" ]] + [[ "${lines[2]}" == "" ]] +} + # help ######################################################################## @test "\`help list\` exits with status 0." { diff --git a/test/search.bats b/test/search.bats index e821907..71ab206 100644 --- a/test/search.bats +++ b/test/search.bats @@ -149,6 +149,23 @@ Description: [[ "${lines[2]}" == "" ]] } +@test "\`search \` prints disabled records with matching comments." { + { + run "${_HOSTS}" add 0.0.0.0 example.com + run "${_HOSTS}" add 0.0.0.0 example.net "Example Comment" + run "${_HOSTS}" add 127.0.0.1 example.com + run "${_HOSTS}" add 127.0.0.1 example.biz "Example Comment" + run "${_HOSTS}" disable example.biz + } + + run "${_HOSTS}" search "Comment" + printf "\${status}: %s\\n" "${status}" + printf "\${output}: '%s'\\n" "${output}" + [[ "${lines[0]}" == "0.0.0.0 example.net # Example Comment" ]] + [[ "${lines[1]}" == "disabled: 127.0.0.1 example.biz # Example Comment" ]] + [[ "${lines[2]}" == "" ]] +} + # help ######################################################################## @test "\`help search\` exits with status 0." { diff --git a/test/show.bats b/test/show.bats index 4b8fd54..017a782 100644 --- a/test/show.bats +++ b/test/show.bats @@ -85,7 +85,7 @@ load test_helper # `hosts show ` ################################################ -@test "\`list \` exits with status 0." { +@test "\`show \` exits with status 0." { { run "${_HOSTS}" add 0.0.0.0 example.com run "${_HOSTS}" add 0.0.0.0 example.net @@ -98,7 +98,7 @@ load test_helper [[ ${status} -eq 0 ]] } -@test "\`list \` prints list of matching records." { +@test "\`show \` prints list of matching records." { { run "${_HOSTS}" add 0.0.0.0 example.com run "${_HOSTS}" add 0.0.0.0 example.net @@ -113,7 +113,7 @@ load test_helper [[ "${lines[2]}" == "" ]] } -@test "\`search \` prints records with matching comments." { +@test "\`show \` prints records with matching comments." { { run "${_HOSTS}" add 0.0.0.0 example.com run "${_HOSTS}" add 0.0.0.0 example.net "Example Comment" @@ -127,6 +127,23 @@ load test_helper [[ "${lines[2]}" == "" ]] } +@test "\`show \` prints disabled records with matching comments." { + { + run "${_HOSTS}" add 0.0.0.0 example.com + run "${_HOSTS}" add 0.0.0.0 example.net "Example Comment" + run "${_HOSTS}" add 127.0.0.1 example.com + run "${_HOSTS}" add 127.0.0.1 example.biz "Example Comment" + run "${_HOSTS}" disable example.biz + } + + run "${_HOSTS}" show "Comment" + printf "\${status}: %s\\n" "${status}" + printf "\${output}: '%s'\\n" "${output}" + [[ "${lines[0]}" == "0.0.0.0 example.net # Example Comment" ]] + [[ "${lines[1]}" == "disabled: 127.0.0.1 example.biz # Example Comment" ]] + [[ "${lines[2]}" == "" ]] +} + # help ######################################################################## @test "\`help show\` exits with status 0." {