From daa55277149121de47d48e714b167f1a1f7778ac Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 9 Nov 2024 16:42:45 +0100 Subject: [PATCH] chore: simplify skip with return --- src/skip_todo.sh | 3 --- tests/acceptance/bashunit_upgrade_test.sh | 20 +++++++++----------- tests/acceptance/install_test.sh | 12 ++++-------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/skip_todo.sh b/src/skip_todo.sh index 04adbe7d..c636ed9a 100755 --- a/src/skip_todo.sh +++ b/src/skip_todo.sh @@ -8,9 +8,6 @@ function skip() { console_results::print_skipped_test "${label}" "${reason}" state::add_assertions_skipped - - # Stop the current test function execution - return 0 } function todo() { diff --git a/tests/acceptance/bashunit_upgrade_test.sh b/tests/acceptance/bashunit_upgrade_test.sh index 6e57c7bf..c51c3479 100644 --- a/tests/acceptance/bashunit_upgrade_test.sh +++ b/tests/acceptance/bashunit_upgrade_test.sh @@ -26,19 +26,18 @@ function tear_down() { } function test_do_not_upgrade_when_latest() { - skip "failing when having a new release" - return -# local output -# output="$($TMP_BIN --upgrade)" -# -# assert_same "> You are already on latest version" "$output" -# assert_string_ends_with "$LATEST_VERSION" "$($TMP_BIN --version --env "$TEST_ENV_FILE")" + skip "failing when having a new release" && return + + local output + output="$($TMP_BIN --upgrade)" + + assert_same "> You are already on latest version" "$output" + assert_string_ends_with "$LATEST_VERSION" "$($TMP_BIN --version --env "$TEST_ENV_FILE")" } function test_upgrade_when_a_new_version_found() { if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then - skip "no internet connection" - return + skip "no internet connection" && return fi sed -i -e \ @@ -59,8 +58,7 @@ function test_upgrade_when_a_new_version_found() { function test_do_not_update_on_consecutive_calls() { if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then - skip "no internet connection" - return + skip "no internet connection" && return fi sed -i -e \ diff --git a/tests/acceptance/install_test.sh b/tests/acceptance/install_test.sh index 5b098c4e..001474bd 100644 --- a/tests/acceptance/install_test.sh +++ b/tests/acceptance/install_test.sh @@ -27,8 +27,7 @@ function tear_down() { function test_install_downloads_the_latest_version() { if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then - skip "no internet connection" - return + skip "no internet connection" && return fi local installed_bashunit="./lib/bashunit" @@ -47,8 +46,7 @@ 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 + skip "no internet connection" && return fi local installed_bashunit="./deps/bashunit" @@ -67,8 +65,7 @@ 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 + skip "no internet connection" && return fi local installed_bashunit="./lib/bashunit" @@ -89,8 +86,7 @@ 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 + skip "no internet connection" && return fi mock date echo "2023-11-13"