1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-05-28 12:20:47 +00:00
hosts/test/file.bats
William Melody 80edd464b6 Use explicit escaping for "\\n" newlines.
Backslash is literal, so explicitly escape it rather than rely on
fallback behavior.

ShellCheck SC1117
https://github.com/koalaman/shellcheck/wiki/SC1117
2018-04-15 14:55:26 -07:00

29 lines
668 B
Bash

#!/usr/bin/env bats
load test_helper
@test "\`file\` exits with status 0." {
run "${_HOSTS}" file
[ "${status}" -eq 0 ]
}
@test "\`file\` prints \$HOSTS_PATH contents." {
run "${_HOSTS}" file
[[ "${output}" == "$(cat ${HOSTS_PATH})" ]]
}
# help ########################################################################
@test "\`help file\` exits with status 0." {
run "${_HOSTS}" help file
[[ ${status} -eq 0 ]]
}
@test "\`help file\` prints help information." {
run "${_HOSTS}" help file
printf "\${status}: %s\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"
[[ "${lines[0]}" == "Usage:" ]]
[[ "${lines[1]}" == " hosts file" ]]
}