summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-19 21:08:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-19 21:13:29 +0000
commit8e08e1a1fd6ba8f85cc71c5fd077e60c6062a4ce (patch)
tree59562954ab5baf1c981924dadd555bae409e9ad2
parent2503321da3d58a1c51b4f7dd8b14a33a29e4b5aa (diff)
downloadalpine-conf-8e08e1a1fd6ba8f85cc71c5fd077e60c6062a4ce.zip
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.
-rwxr-xr-xtests/bin/wget7
-rwxr-xr-xtests/fake_wget_test19
2 files changed, 25 insertions, 1 deletions
diff --git a/tests/bin/wget b/tests/bin/wget
index 72306a4..5efc612 100755
--- a/tests/bin/wget
+++ b/tests/bin/wget
@@ -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"
diff --git a/tests/fake_wget_test b/tests/fake_wget_test
index dac7681..c8c4152 100755
--- a/tests/fake_wget_test
+++ b/tests/fake_wget_test
@@ -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
+}
+