Skip to content

Commit 2197934

Browse files
committed
skip upgrade tests if no git found
1 parent e78ee50 commit 2197934

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

src/assert_snapshot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function snapshot::compare() {
8181
if ! snapshot::match_with_placeholder "$actual" "$snapshot"; then
8282
local label=$(helper::normalize_test_function_name "$func_name")
8383
state::add_assertions_failed
84-
console_results::print_failed_snapshot_test "$label" "$snapshot_path"
84+
console_results::print_failed_snapshot_test "$label" "$snapshot_path" "$actual"
8585
return 1
8686
fi
8787

src/console_results.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,15 @@ ${_COLOR_FAILED}✗ Failed${_COLOR_DEFAULT}: %s
185185
function console_results::print_failed_snapshot_test() {
186186
local function_name=$1
187187
local snapshot_file=$2
188+
local actual_content=${3-}
188189

189190
local line
190191
line="$(printf "${_COLOR_FAILED}✗ Failed${_COLOR_DEFAULT}: %s
191192
${_COLOR_FAINT}Expected to match the snapshot${_COLOR_DEFAULT}\n" "$function_name")"
192193

193194
if dependencies::has_git; then
194195
local actual_file="${snapshot_file}.tmp"
195-
echo "$actual" > "$actual_file"
196+
echo "$actual_content" > "$actual_file"
196197

197198
local git_diff_output
198199
git_diff_output="$(git diff --no-index --word-diff --color=always \

tests/acceptance/bashunit_upgrade_test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ set +e
55
TMP_DIR="tmp"
66
TMP_BIN="$TMP_DIR/bashunit"
77
ACTIVE_INTERNET=0
8+
HAS_DOWNLOADER=0
9+
HAS_GIT=0
810

911
function set_up_before_script() {
1012
env::active_internet_connection
1113
ACTIVE_INTERNET=$?
14+
if dependencies::has_curl || dependencies::has_wget; then
15+
HAS_DOWNLOADER=1
16+
fi
17+
if dependencies::has_git; then
18+
HAS_GIT=1
19+
fi
1220
}
1321

1422
function tear_down_after_script() {
@@ -39,6 +47,12 @@ function test_upgrade_when_a_new_version_found() {
3947
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
4048
skip "no internet connection" && return
4149
fi
50+
if [[ "$HAS_GIT" -eq 0 ]]; then
51+
skip "git not installed" && return
52+
fi
53+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
54+
skip "curl or wget not installed" && return
55+
fi
4256

4357
sed -i -e \
4458
's/declare -r BASHUNIT_VERSION="[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}"/declare -r BASHUNIT_VERSION="0.1.0"/' \
@@ -60,6 +74,12 @@ function test_do_not_update_on_consecutive_calls() {
6074
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
6175
skip "no internet connection" && return
6276
fi
77+
if [[ "$HAS_GIT" -eq 0 ]]; then
78+
skip "git not installed" && return
79+
fi
80+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
81+
skip "curl or wget not installed" && return
82+
fi
6383

6484
sed -i -e \
6585
's/declare -r BASHUNIT_VERSION="[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}"/declare -r BASHUNIT_VERSION="0.1.0"/' \

tests/acceptance/install_test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ set -uo pipefail
44
set +e
55

66
ACTIVE_INTERNET=0
7+
HAS_DOWNLOADER=0
8+
HAS_GIT=0
79

810
function set_up_before_script() {
911
env::active_internet_connection
1012
ACTIVE_INTERNET=$?
1113
TEST_ENV_FILE="./tests/acceptance/fixtures/.env.default"
14+
if dependencies::has_curl || dependencies::has_wget; then
15+
HAS_DOWNLOADER=1
16+
fi
17+
if dependencies::has_git; then
18+
HAS_GIT=1
19+
fi
1220
}
1321

1422
function tear_down_after_script() {
@@ -29,6 +37,9 @@ function test_install_downloads_the_latest_version() {
2937
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
3038
skip "no internet connection" && return
3139
fi
40+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
41+
skip "curl or wget not installed" && return
42+
fi
3243

3344
local installed_bashunit="./lib/bashunit"
3445
local output
@@ -48,6 +59,9 @@ function test_install_downloads_in_given_folder() {
4859
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
4960
skip "no internet connection" && return
5061
fi
62+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
63+
skip "curl or wget not installed" && return
64+
fi
5165

5266
local installed_bashunit="./deps/bashunit"
5367
local output
@@ -67,6 +81,9 @@ function test_install_downloads_the_given_version() {
6781
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
6882
skip "no internet connection" && return
6983
fi
84+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
85+
skip "curl or wget not installed" && return
86+
fi
7087

7188
local installed_bashunit="./lib/bashunit"
7289
local output
@@ -88,6 +105,9 @@ function test_install_downloads_the_given_version_without_dir() {
88105
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
89106
skip "no internet connection" && return
90107
fi
108+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
109+
skip "curl or wget not installed" && return
110+
fi
91111

92112
local installed_bashunit="./lib/bashunit"
93113
local output
@@ -111,6 +131,12 @@ function test_install_downloads_the_non_stable_beta_version() {
111131
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
112132
skip "no internet connection" && return
113133
fi
134+
if [[ "$HAS_GIT" -eq 0 ]]; then
135+
skip "git not installed" && return
136+
fi
137+
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
138+
skip "curl or wget not installed" && return
139+
fi
114140

115141
mock date echo "2023-11-13"
116142
mock tput echo ""

0 commit comments

Comments
 (0)