From 8e7b385315e9e360e1d2b7094e6b0f85f0d224a0 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 9 Nov 2024 16:09:25 +0100 Subject: [PATCH] chore: skip install_tests when no internet connection --- tests/acceptance/bashunit_upgrade_test.sh | 6 +++++ tests/acceptance/install_test.sh | 32 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/bashunit_upgrade_test.sh b/tests/acceptance/bashunit_upgrade_test.sh index 59e16ca9..6e57c7bf 100644 --- a/tests/acceptance/bashunit_upgrade_test.sh +++ b/tests/acceptance/bashunit_upgrade_test.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -uo pipefail +set +e TMP_DIR="tmp" TMP_BIN="$TMP_DIR/bashunit" @@ -9,6 +11,10 @@ function set_up_before_script() { ACTIVE_INTERNET=$? } +function tear_down_after_script() { + set -e +} + function set_up() { ./build.sh "$TMP_DIR" >/dev/null LATEST_VERSION="$(helpers::get_latest_tag)" diff --git a/tests/acceptance/install_test.sh b/tests/acceptance/install_test.sh index c5f51449..5b098c4e 100644 --- a/tests/acceptance/install_test.sh +++ b/tests/acceptance/install_test.sh @@ -1,10 +1,20 @@ #!/bin/bash -set -euo pipefail +# shellcheck disable=SC2317 +set -uo pipefail +set +e + +ACTIVE_INTERNET=0 function set_up_before_script() { + env::active_internet_connection + ACTIVE_INTERNET=$? TEST_ENV_FILE="./tests/acceptance/fixtures/.env.default" } +function tear_down_after_script() { + set -e +} + function set_up() { rm -f ./lib/bashunit rm -f ./deps/bashunit @@ -16,6 +26,11 @@ function tear_down() { } function test_install_downloads_the_latest_version() { + if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then + skip "no internet connection" + return + fi + local installed_bashunit="./lib/bashunit" local output @@ -31,6 +46,11 @@ function test_install_downloads_the_latest_version() { } function test_install_downloads_in_given_folder() { + if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then + skip "no internet connection" + return + fi + local installed_bashunit="./deps/bashunit" local output @@ -46,6 +66,11 @@ function test_install_downloads_in_given_folder() { } function test_install_downloads_the_given_version() { + if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then + skip "no internet connection" + return + fi + local installed_bashunit="./lib/bashunit" local output @@ -63,6 +88,11 @@ function test_install_downloads_the_given_version() { } function test_install_downloads_the_non_stable_beta_version() { + if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then + skip "no internet connection" + return + fi + mock date echo "2023-11-13" mock tput echo "" local installed_bashunit="./deps/bashunit"