tests: abuild-fetch: test wget fallback

if curl is unavailable wget should be called
This commit is contained in:
Natanael Copa 2021-04-20 11:26:19 +02:00
parent d708a813a3
commit cb9ac5be89
1 changed files with 24 additions and 0 deletions

View File

@ -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 ]
}