hurl/integration/ad_hoc.sh
2022-12-15 18:09:44 +01:00

35 lines
961 B
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -Eeuo pipefail
# Add ad-hoc tests that can't be easily added in tests_ok/ nor tests_failed/
function assert_equals() {
if [ "$1" != "$2" ]; then
echo "Error differs:"
echo "actual: $1"
echo "expected: $2"
exit 1
fi
}
echo "Check file not found error"
actual=$(hurl does_not_exist.hurl 2>&1 || true)
expected="error: hurl: cannot access 'does_not_exist.hurl': No such file or directory"
assert_equals "$actual" "$expected"
echo "Check multiple Hurl files"
actual=$(hurl tests_ok/hello.hurl tests_ok/hello.hurl)
expected="Hello World!Hello World!"
assert_equals "$actual" "$expected"
echo "Check stdin"
actual=$(echo 'GET http://localhost:8000/hello' | hurl)
expected="Hello World!"
assert_equals "$actual" "$expected"
echo "Check hurlfmt --color"
actual=$(echo 'GET http://localhost:8000/hello' | hurlfmt --color)
expected="GET http://localhost:8000/hello"
assert_equals "$actual" "$expected"