From 8b704f5f61933e6749cf6dad25127bc99c1b7681 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 28 Jun 2022 12:32:24 +0200 Subject: tests: make fake wget to error on missing/or empty url --- tests/bin/wget | 5 +++++ tests/fake_wget_test | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) 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 "" +} + -- cgit v1.2.3