Commit 50027f0e authored by Vojtěch Horký's avatar Vojtěch Horký
Browse files

Assertion improvements

parent 42b791a4
......@@ -47,6 +47,32 @@ assert_file_not_committed() {
fi
}
assert_file_has_mime_type() {
local filename="${1:-}"
local expected_mime_type="${2:-}"
local message="${msg:-Wrong file MIME type}"
if ! [ -f "${filename}" ]; then
fail "File ${filename} not found (want ${expected_mime_type})"
fi
local actual_mime_type
actual_mime_type="$( file -b --mime-type "${filename}" )"
case "${actual_mime_type}" in
${expected_mime_type})
;;
*)
batslib_print_kv_single_or_multi 10 \
'filename' "${filename}" \
'actual' "${actual_mime_type}" \
'expected' "${expected_mime_type}" \
| batslib_decorate "${message}" \
| fail
;;
esac
}
assert_equals() {
local expected="${1:-}"
local actual="${2:-}"
......
......@@ -90,8 +90,13 @@ assert_uses_pipes_only() {
assert_is_shellchecked() {
local severity="${1:-info}"
local script="${script:-}"
run shellcheck -S "$severity" "${NSWI177_MAIN_SCRIPT:?}" --format gcc
if [[ -z "${script}" ]]; then
script="${NSWI177_MAIN_SCRIPT:?}"
fi
run shellcheck -S "$severity" "${script}" --format gcc
if [ "$status" -ne 0 ]; then
echo "$output" \
| batslib_decorate "Shellcheck found following issues (severity $severity)" \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment