1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-24 13:47:35 +00:00

Improve formatting in tests.

This commit is contained in:
William Melody 2020-05-17 11:33:57 -07:00
parent 1d948837d0
commit 8f6a700909
8 changed files with 40 additions and 40 deletions

View File

@ -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 <hostname>..." ]]
}
# `hosts block <hostname>` #################################################
# `hosts block <hostname>` ####################################################
@test "\`block <hostname>\` exits with status 0." {
run "${_HOSTS}" block example.com

View File

@ -2,7 +2,7 @@
load test_helper
# `hosts disabled` #############################################################
# `hosts disabled` ############################################################
@test "\`disabled\` with no arguments exits with status 0." {
{

View File

@ -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]}" == "" ]]
}

View File

@ -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` #######################################################

View File

@ -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 <ip>\` removes all matches." {

View File

@ -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 <search string>" ]]
[[ "${lines[0]}" == "Usage:" ]]
[[ "${lines[1]}" == " hosts search <search string>" ]]
}

View File

@ -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 <ip>` #########################################################
# `hosts show <ip>` ###########################################################
@test "\`show <ip>\` 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 <search string>` ################################################
@ -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]}" == "" ]]
}

View File

@ -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 <hostname>..." ]]
}
# `hosts unblock <invalid>` ############################################
# `hosts unblock <invalid>` ###################################################
@test "\`unblock <invalid> \` exits with status 1." {
{
@ -52,7 +52,7 @@ load test_helper
[[ ${output} == "${_ERROR_PREFIX}No matching records found." ]]
}
# `hosts unblock <hostname>` ###########################################
# `hosts unblock <hostname>` ##################################################
@test "\`unblock <hostname>\` exits with status 0." {
{