diff --git a/tests/abuild-fetch.bats b/tests/abuild-fetch.bats index fea3ac6..89000fc 100644 --- a/tests/abuild-fetch.bats +++ b/tests/abuild-fetch.bats @@ -15,6 +15,18 @@ setup() { exit \${CURL_EXITCODE:-0} EOF chmod +x "$bindir"/curl + + # fake wget + cat >> "$bindir"/wget <<-EOF + #!/bin/sh + + PATH=/usr/local/bin:/usr/bin:/bin + touch "$tmpdir"/wget-invoked + echo "Fake wget invoked with: \$@" + exit \${WGET_EXITCODE:-0} + EOF + chmod +x "$bindir"/wget + } teardown() { @@ -34,3 +46,15 @@ teardown() { run CURL_EXITCODE=1 $ABUILD_FETCH -d "$tmpdir" https://example.com/non-existing [ $status -ne 0 ] } + +@test "abuild-fetch: test wget fallback" { + rm "$bindir"/curl + PATH="$bindir" $ABUILD_FETCH -d "$tmpdir" https://example.com/non-existing + [ -f "$tmpdir"/wget-invoked ] +} + +@test "abuild-fetch: test wget fallback failure" { + rm "$bindir"/curl + run PATH="$bindir" WGET_EXITCODE=1 $ABUILD_FETCH -d "$tmpdir" https://example.com/non-existing + [ $status -ne 0 ] +}