Commit 8e08e1a1 authored by Natanael Copa's avatar Natanael Copa
Browse files

tests: make it possible to simluate wget failure

Make it possible to simulate wget errors by fetching an URL with 'fail'
or '404' in the URL string. 'fail' results in DNS error(ish) and '404'
returns a 404 error message.
parent 2503321d
......@@ -63,6 +63,13 @@ while true; do
shift
done
for url; do
case "$url" in
*fail*) msg "bad address"; exit 1;;
*404*) msg "wget: server returned error: HTTP/1.1 404 Not Found"; exit 1;;
esac
done
: ${outfile:=index.html}
case "$outfile" in
-) msg "writing to stdout"
......
......@@ -7,7 +7,9 @@ init_tests \
fake_wget_quiet \
fake_wget \
fake_wget_outfile \
fake_wget_stdout
fake_wget_stdout \
fake_wget_fail \
fake_wget_404
fake_wget_usage_body() {
test_usage wget
......@@ -56,3 +58,18 @@ fake_wget_stdout_body() {
wget -O - https://example.com
! test -f - || atf_fail "- was created"
}
fake_wget_fail_body() {
init_env
atf_check -s exit:1 \
-e match:"bad address" \
wget https://example.com/fail
}
fake_wget_404_body() {
init_env
atf_check -s exit:1 \
-e match:"404 Not Found" \
wget https://example.com/404
}
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