From 0c40d8aca72c2dd2459e86d7b61668a1de39b41c Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 14 Jun 2022 17:52:05 +0200 Subject: [PATCH] tests: abuild-fetch: test wget fallback --- tests/abuild_fetch_test | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/abuild_fetch_test b/tests/abuild_fetch_test index 94696da..9e7e8d4 100755 --- a/tests/abuild_fetch_test +++ b/tests/abuild_fetch_test @@ -5,7 +5,8 @@ init_tests \ abuild_fetch_help \ abuild_fetch_curl_invocation \ abuild_fetch_curl_failure \ - abuild_fetch_curl_insecure + abuild_fetch_curl_insecure \ + abuild_fetch_wget_fallback create_fake_curl() { mkdir bin @@ -24,6 +25,17 @@ create_fake_curl() { PATH="$PWD/bin:$PATH" } +create_fake_wget() { + mkdir -p bin + cat > bin/wget <<-EOF + #!/bin/sh + + echo "Fake wget invoked with: \$@" + exit \${WGET_EXITCODE:-0} + EOF + chmod +x bin/wget +} + abuild_fetch_help_body() { atf_check -s exit:0 \ -o not-empty \ @@ -59,3 +71,11 @@ abuild_fetch_curl_insecure_body() { abuild-fetch http://example.com/non-existing } +abuild_fetch_wget_fallback_body() { + create_fake_wget + PATH="$PWD/bin:$(atf_get_srcdir)/.." atf_check -s exit:0 \ + -o match:"Fake wget invoked" \ + -e empty \ + abuild-fetch https://example.com/non-existing +} +