Fix BATS gravity test on curl version >=8.21

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König 2026-07-04 12:23:02 +02:00
parent aac48b75ed
commit 20ed2ab95f
No known key found for this signature in database

View file

@ -14,10 +14,13 @@ INFO="[i]"
# Depending on the curl version, a specific error messages can be returned in case of failure
curlVersion=$(curl --version | awk '{print $2;exit}')
if echo "${curlVersion%.*}" | awk '{exit !($1 - 7.75 >= 0)}'; then
if echo "${curlVersion%.*}" | awk '{exit !($1 - 8.21 >= 0)}'; then
curl821=true
elif echo "${curlVersion%.*}" | awk '{exit !($1 - 7.75 >= 0)}'; then
curl775=true
fi
# Really old curl versions miss a fix for using --etag-save and --etag-compare together (https://github.com/curl/curl/pull/5180)
# Fixed in curl 7.70.0 - April 29 2020
if echo "${curlVersion%.*}" | awk '{exit !($1 - 7.70 >= 0)}'; then
@ -233,7 +236,9 @@ teardown() {
assert_line --partial "${INFO} Migrating content of /etc/pihole/adlists.list into new database"
assert_line --partial "${INFO} Target: http://localhost:81/list"
if [ "${curl775}" = true ]; then
if [ "${curl821}" = true ]; then
assert_line --partial "${CROSS} Status: Retrieval failed (exit_code=7 Msg: Failed to connect to localhost:81"
elif [ "${curl775}" = true ]; then
assert_line --partial "${CROSS} Status: Retrieval failed (exit_code=7 Msg: Failed to connect to localhost port 81"
else
assert_line --partial "${CROSS} Status: Retrieval failed (exit_code=7 Msg: No message available. Non supported curl version.)"