summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-06-28 12:32:24 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2022-06-28 12:45:08 +0200
commit8b704f5f61933e6749cf6dad25127bc99c1b7681 (patch)
treec179c44c79da42515b3be73a2c899c4ee17fc99d
parentc51ebcb7f5b3f093e6b7bbffcc1213d83f30c86f (diff)
downloadalpine-conf-8b704f5f61933e6749cf6dad25127bc99c1b7681.zip
tests: make fake wget to error on missing/or empty url
-rwxr-xr-xtests/bin/wget5
-rwxr-xr-xtests/fake_wget_test18
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/bin/wget b/tests/bin/wget
index 5efc612..77144b9 100755
--- a/tests/bin/wget
+++ b/tests/bin/wget
@@ -63,8 +63,13 @@ while true; do
shift
done
+if [ $# -eq 0 ]; then
+ usage "1" >&2
+fi
+
for url; do
case "$url" in
+ "") msg "bad address"; exit 1;;
*fail*) msg "bad address"; exit 1;;
*404*) msg "wget: server returned error: HTTP/1.1 404 Not Found"; exit 1;;
esac
diff --git a/tests/fake_wget_test b/tests/fake_wget_test
index c8c4152..f6c33fc 100755
--- a/tests/fake_wget_test
+++ b/tests/fake_wget_test
@@ -9,7 +9,9 @@ init_tests \
fake_wget_outfile \
fake_wget_stdout \
fake_wget_fail \
- fake_wget_404
+ fake_wget_404 \
+ fake_wget_missing_url \
+ fake_wget_empty_url
fake_wget_usage_body() {
test_usage wget
@@ -73,3 +75,17 @@ fake_wget_404_body() {
wget https://example.com/404
}
+fake_wget_missing_url_body() {
+ init_env
+ atf_check -s exit:1 \
+ -e match:"usage:" \
+ wget -q -O -
+}
+
+fake_wget_empty_url_body() {
+ init_env
+ atf_check -s exit:1 \
+ -e match:"bad address" \
+ wget ""
+}
+