1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-22 04:45:11 +00:00

Improve test failure messages.

This commit is contained in:
William Melody 2020-04-12 16:09:12 -07:00
parent c41b0ada74
commit 16c7484c17
2 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,8 @@ load test_helper
run "${_HOSTS}" backups run "${_HOSTS}" backups
printf "\${status}: %s\\n" "${status}" printf "\${status}: %s\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}" printf "\${output}: '%s'\\n" "${output}"
printf "\${_HOSTS_TEMP_PATH}: '%s'\\n" "${_HOSTS_TEMP_PATH}"
printf "\${HOSTS_PATH}: '%s'\\n" "${HOSTS_PATH}"
_expected="\ _expected="\
No backups found. Create a new backup: No backups found. Create a new backup:
hosts backups create" hosts backups create"
@ -42,6 +44,8 @@ No backups found. Create a new backup:
run "${_HOSTS}" backups run "${_HOSTS}" backups
printf "\${status}: %s\\n" "${status}" printf "\${status}: %s\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}" printf "\${output}: '%s'\\n" "${output}"
printf "\${_HOSTS_TEMP_PATH}: '%s'\\n" "${_HOSTS_TEMP_PATH}"
printf "\${HOSTS_PATH}: '%s'\\n" "${HOSTS_PATH}"
[[ "${lines[0]}" =~ hosts_test ]] [[ "${lines[0]}" =~ hosts_test ]]
[[ "${lines[0]}" =~ '--backup-' ]] [[ "${lines[0]}" =~ '--backup-' ]]
[[ "${lines[1]}" =~ hosts_test ]] [[ "${lines[1]}" =~ hosts_test ]]

View File

@ -14,7 +14,7 @@ setup() {
export _HOSTS_TEMP_DIR="/tmp" export _HOSTS_TEMP_DIR="/tmp"
export _HOSTS_TEMP_PATH export _HOSTS_TEMP_PATH
_HOSTS_TEMP_PATH="$(mktemp ${_HOSTS_TEMP_DIR}/hosts_test.XXXXXX)" || exit 1 _HOSTS_TEMP_PATH="$(mktemp "${_HOSTS_TEMP_DIR}/hosts_test.XXXXXX")" || exit 1
cat "${BATS_TEST_DIRNAME}/fixtures/hosts" > "${_HOSTS_TEMP_PATH}" cat "${BATS_TEST_DIRNAME}/fixtures/hosts" > "${_HOSTS_TEMP_PATH}"
export HOSTS_PATH="${_HOSTS_TEMP_PATH}" export HOSTS_PATH="${_HOSTS_TEMP_PATH}"