1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-06-07 00:40:50 +00:00

Add _compare() function to test_helper.bash.

This commit is contained in:
William Melody 2016-01-25 17:20:10 -08:00
parent 8e267fafd7
commit 8faa7a0ab6

View File

@ -24,3 +24,22 @@ teardown() {
rm "${HOSTS_PATH}" rm "${HOSTS_PATH}"
fi fi
} }
###############################################################################
# Helpers
###############################################################################
# _compare()
#
# Usage:
# _compare <expected> <actual>
#
# Descriotion:
# Compare the content of a variable against an expected value. When used
# within a `@test` block the output is only displayed when the test fails.
_compare() {
local _expected="${1:-}"
local _actual="${2:-}"
printf "expected:\n%s\n" "${_expected}"
printf "actual:\n%s\n" "${_actual}"
}