2022-07-02 07:08:26 +03:00
|
|
|
|
#!/bin/bash
|
2022-12-14 11:28:25 +03:00
|
|
|
|
set -Eeuo pipefail
|
|
|
|
|
|
2022-07-20 14:11:54 +03:00
|
|
|
|
# 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
|
|
|
|
|
}
|
2022-07-02 07:08:26 +03:00
|
|
|
|
|
|
|
|
|
echo "Check file not found error"
|
2022-12-14 16:28:49 +03:00
|
|
|
|
actual=$(hurl does_not_exist.hurl 2>&1 || true)
|
2022-07-02 07:08:26 +03:00
|
|
|
|
expected="error: hurl: cannot access 'does_not_exist.hurl': No such file or directory"
|
2022-07-20 14:11:54 +03:00
|
|
|
|
assert_equals "$actual" "$expected"
|
2022-07-02 07:08:26 +03:00
|
|
|
|
|
2022-07-02 15:37:55 +03:00
|
|
|
|
echo "Check multiple Hurl files"
|
|
|
|
|
actual=$(hurl tests_ok/hello.hurl tests_ok/hello.hurl)
|
|
|
|
|
expected="Hello World!Hello World!"
|
2022-07-20 14:11:54 +03:00
|
|
|
|
assert_equals "$actual" "$expected"
|
|
|
|
|
|
|
|
|
|
echo "Check stdin"
|
|
|
|
|
actual=$(echo 'GET http://localhost:8000/hello' | hurl)
|
|
|
|
|
expected="Hello World!"
|
|
|
|
|
assert_equals "$actual" "$expected"
|
2022-11-05 03:17:23 +03:00
|
|
|
|
|
|
|
|
|
echo "Check hurlfmt --color"
|
|
|
|
|
actual=$(echo 'GET http://localhost:8000/hello' | hurlfmt --color)
|
|
|
|
|
expected="[33mGET[0m [32mhttp://localhost:8000/hello[0m"
|
|
|
|
|
assert_equals "$actual" "$expected"
|
2022-12-14 11:28:25 +03:00
|
|
|
|
|