From 8f6a7009090a1a38fe962c7f5db8543fd8b6f607 Mon Sep 17 00:00:00 2001 From: William Melody Date: Sun, 17 May 2020 11:33:57 -0700 Subject: [PATCH] Improve formatting in tests. --- test/block.bats | 4 ++-- test/disabled.bats | 2 +- test/hosts.bats | 8 ++++---- test/list.bats | 10 +++++----- test/remove.bats | 8 ++++---- test/search.bats | 30 +++++++++++++++--------------- test/show.bats | 12 ++++++------ test/unblock.bats | 6 +++--- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/block.bats b/test/block.bats index 20a2041..c626eae 100644 --- a/test/block.bats +++ b/test/block.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts block` ################################################################# +# `hosts block` ############################################################### @test "\`block\` with no arguments exits with status 1." { run "${_HOSTS}" block @@ -28,7 +28,7 @@ load test_helper [[ "${lines[1]}" == " hosts block ..." ]] } -# `hosts block ` ################################################# +# `hosts block ` #################################################### @test "\`block \` exits with status 0." { run "${_HOSTS}" block example.com diff --git a/test/disabled.bats b/test/disabled.bats index 34702b9..5a93525 100644 --- a/test/disabled.bats +++ b/test/disabled.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts disabled` ############################################################# +# `hosts disabled` ############################################################ @test "\`disabled\` with no arguments exits with status 0." { { diff --git a/test/hosts.bats b/test/hosts.bats index 5b48d55..04f53d7 100644 --- a/test/hosts.bats +++ b/test/hosts.bats @@ -10,9 +10,9 @@ load test_helper @test "\`hosts\` with no arguments prints enabled rules." { run "${_HOSTS}" [[ "${#lines[@]}" -eq 4 ]] - [[ "${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[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]}" == "" ]] } diff --git a/test/list.bats b/test/list.bats index 7695a7d..b189d71 100644 --- a/test/list.bats +++ b/test/list.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts list` ############################################################# +# `hosts list` ################################################################ @test "\`list\` exits with status 0." { { @@ -71,11 +71,11 @@ Disabled: run "${_HOSTS}" list enabled printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" =~ 127\.0\.0\.1[[:space:]]+localhost ]] + [[ "${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 ]] + [[ "${lines[2]}" =~ \:\:1[[:space:]]+localhost ]] + [[ "${lines[3]}" =~ fe80\:\:1\%lo0[[:space:]]+localhost ]] + [[ "${lines[4]}" =~ 127\.0\.0\.2[[:space:]]+example.com ]] } # `hosts list disabled` ####################################################### diff --git a/test/remove.bats b/test/remove.bats index 37924f0..f584caf 100644 --- a/test/remove.bats +++ b/test/remove.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts remove` ################################################################# +# `hosts remove` ############################################################## @test "\`remove\` with no arguments exits with status 1." { run "${_HOSTS}" remove @@ -83,9 +83,9 @@ load test_helper printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" _compare "${_original}" "$(cat "${HOSTS_PATH}")" - [[ "$(sed -n '11p' "${HOSTS_PATH}")" =~ 0.0.0.0[[:space:]]+example.com ]] - [[ "$(sed -n '12p' "${HOSTS_PATH}")" =~ 0.0.0.0[[:space:]]+example.net ]] - [[ "$(sed -n '13p' "${HOSTS_PATH}")" == "" ]] + [[ "$(sed -n '11p' "${HOSTS_PATH}")" =~ 0.0.0.0[[:space:]]+example.com ]] + [[ "$(sed -n '12p' "${HOSTS_PATH}")" =~ 0.0.0.0[[:space:]]+example.net ]] + [[ "$(sed -n '13p' "${HOSTS_PATH}")" == "" ]] } @test "\`remove \` removes all matches." { diff --git a/test/search.bats b/test/search.bats index 360e6d1..c430cc6 100644 --- a/test/search.bats +++ b/test/search.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts search` ############################################################# +# `hosts search` ############################################################## @test "\`search\` with no arguments exits with status 1." { { @@ -66,14 +66,14 @@ Description: run "${_HOSTS}" search enabled printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${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 ]] + [[ "${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 ]] } -# `hosts search disabled` ####################################################### +# `hosts search disabled` ##################################################### @test "\`search disabled\` exits with status 0." { { @@ -100,8 +100,8 @@ Description: run "${_HOSTS}" search disabled printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.com ]] - [[ "${lines[1]}" =~ 127.0.0.1[[:space:]]+example.com ]] + [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.com ]] + [[ "${lines[1]}" =~ 127.0.0.1[[:space:]]+example.com ]] [[ "${lines[2]}" == "" ]] } @@ -130,8 +130,8 @@ Description: run "${_HOSTS}" search example.com printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.com ]] - [[ "${lines[1]}" =~ 127.0.0.1[[:space:]]+example.com ]] + [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.com ]] + [[ "${lines[1]}" =~ 127.0.0.1[[:space:]]+example.com ]] [[ "${lines[2]}" == "" ]] } @@ -161,8 +161,8 @@ Description: run "${_HOSTS}" search "Comment" printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.net[[:space:]]+\#\ Example\ Comment ]] - [[ "${lines[3]}" =~ 127.0.0.1[[:space:]]+example.biz[[:space:]]+\#\ Example\ Comment ]] + [[ "${lines[0]}" =~ 0.0.0.0[[:space:]]+example.net[[:space:]]+\#\ Example\ Comment ]] + [[ "${lines[3]}" =~ 127.0.0.1[[:space:]]+example.biz[[:space:]]+\#\ Example\ Comment ]] [[ "${lines[4]}" == "" ]] } @@ -177,6 +177,6 @@ Description: run "${_HOSTS}" help search printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" == "Usage:" ]] - [[ "${lines[1]}" == " hosts search " ]] + [[ "${lines[0]}" == "Usage:" ]] + [[ "${lines[1]}" == " hosts search " ]] } diff --git a/test/show.bats b/test/show.bats index 8aa4924..7aede6a 100644 --- a/test/show.bats +++ b/test/show.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts show` ############################################################## +# `hosts show` ################################################################ @test "\`show\` with no arguments exits with status 1." { run "${_HOSTS}" show @@ -37,7 +37,7 @@ load test_helper [[ "${lines[0]}" =~ No\ matching\ entries ]] } -# `hosts show ` ######################################################### +# `hosts show ` ########################################################### @test "\`show \` exits with status 0 and shows all matches." { { @@ -72,7 +72,7 @@ load test_helper [[ ${status} -eq 0 ]] [[ "${lines[0]}" =~ 127\.0\.0\.2[[:space:]]+example.com ]] - [[ "${lines[3]}" =~ 0\.0\.0\.0[[:space:]]+example.com ]] + [[ "${lines[3]}" =~ 0\.0\.0\.0[[:space:]]+example.com ]] } # `hosts show ` ################################################ @@ -89,7 +89,7 @@ load test_helper printf "\${output}: '%s'\\n" "${output}" [[ ${status} -eq 0 ]] - [[ "${lines[0]}" =~ 0\.0\.0\.0[[:space:]]+example.com ]] + [[ "${lines[0]}" =~ 0\.0\.0\.0[[:space:]]+example.com ]] [[ "${lines[1]}" =~ 127\.0\.0\.1[[:space:]]+example.com ]] [[ "${lines[2]}" == "" ]] } @@ -121,8 +121,8 @@ load test_helper run "${_HOSTS}" show "Comment" printf "\${status}: %s\\n" "${status}" printf "\${output}: '%s'\\n" "${output}" - [[ "${lines[0]}" =~ 0\.0\.0\.0[[:space:]]+example\.net[[:space:]]+\#\ Example\ Comment ]] - [[ "${lines[3]}" =~ 127\.0\.0\.1[[:space:]]+example\.biz[[:space:]]+\#\ Example\ Comment ]] + [[ "${lines[0]}" =~ 0\.0\.0\.0[[:space:]]+example\.net[[:space:]]+\#\ Example\ Comment ]] + [[ "${lines[3]}" =~ 127\.0\.0\.1[[:space:]]+example\.biz[[:space:]]+\#\ Example\ Comment ]] [[ "${lines[4]}" == "" ]] } diff --git a/test/unblock.bats b/test/unblock.bats index 54aad35..54922d4 100644 --- a/test/unblock.bats +++ b/test/unblock.bats @@ -2,7 +2,7 @@ load test_helper -# `hosts unblock` ################################################################# +# `hosts unblock` ############################################################# @test "\`unblock\` with no arguments exits with status 1." { run "${_HOSTS}" unblock @@ -28,7 +28,7 @@ load test_helper [[ "${lines[1]}" == " hosts unblock ..." ]] } -# `hosts unblock ` ############################################ +# `hosts unblock ` ################################################### @test "\`unblock \` exits with status 1." { { @@ -52,7 +52,7 @@ load test_helper [[ ${output} == "${_ERROR_PREFIX}No matching records found." ]] } -# `hosts unblock ` ########################################### +# `hosts unblock ` ################################################## @test "\`unblock \` exits with status 0." { {