tests: abuild-fetch: test wget fallback

This commit is contained in:
Natanael Copa 2022-06-14 17:52:05 +02:00
parent 684cd989e6
commit 0c40d8aca7
1 changed files with 21 additions and 1 deletions

View File

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