Skip to content

Commit 9b9832a

Browse files
committed
refactor: acceptance/bashunit_upgrade_test
1 parent 516df83 commit 9b9832a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tests/acceptance/bashunit_upgrade_test.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ set +e
44

55
TMP_DIR="tmp"
66
TMP_BIN="$TMP_DIR/bashunit"
7-
ACTIVE_INTERNET=0
8-
HAS_DOWNLOADER=0
9-
HAS_GIT=0
7+
ACTIVE_INTERNET=false
8+
HAS_DOWNLOADER=false
9+
HAS_GIT=false
1010

1111
function set_up_before_script() {
1212
env::active_internet_connection
13-
ACTIVE_INTERNET=$?
13+
if [[ $? -eq 0 ]]; then
14+
ACTIVE_INTERNET=true
15+
fi
16+
1417
if dependencies::has_curl || dependencies::has_wget; then
15-
HAS_DOWNLOADER=1
18+
HAS_DOWNLOADER=true
1619
fi
20+
1721
if dependencies::has_git; then
18-
HAS_GIT=1
22+
HAS_GIT=true
1923
fi
2024
}
2125

@@ -44,13 +48,13 @@ function test_do_not_upgrade_when_latest() {
4448
}
4549

4650
function test_upgrade_when_a_new_version_found() {
47-
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
51+
if [[ "$ACTIVE_INTERNET" == false ]]; then
4852
skip "no internet connection" && return
4953
fi
50-
if [[ "$HAS_GIT" -eq 0 ]]; then
54+
if [[ "$HAS_GIT" == false ]]; then
5155
skip "git not installed" && return
5256
fi
53-
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
57+
if [[ "$HAS_DOWNLOADER" == false ]]; then
5458
skip "curl or wget not installed" && return
5559
fi
5660

@@ -71,22 +75,22 @@ function test_upgrade_when_a_new_version_found() {
7175
}
7276

7377
function test_do_not_update_on_consecutive_calls() {
74-
if [[ "$ACTIVE_INTERNET" -eq 1 ]]; then
78+
if [[ "$ACTIVE_INTERNET" == false ]]; then
7579
skip "no internet connection" && return
7680
fi
77-
if [[ "$HAS_GIT" -eq 0 ]]; then
81+
if [[ "$HAS_GIT" == false ]]; then
7882
skip "git not installed" && return
7983
fi
80-
if [[ "$HAS_DOWNLOADER" -eq 0 ]]; then
84+
if [[ "$HAS_DOWNLOADER" == false ]]; then
8185
skip "curl or wget not installed" && return
8286
fi
8387

8488
sed -i -e \
8589
's/declare -r BASHUNIT_VERSION="[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}"/declare -r BASHUNIT_VERSION="0.1.0"/' \
86-
$TMP_BIN
90+
"$TMP_BIN"
8791

8892
if [[ $_OS == "OSX" ]]; then
89-
rm $TMP_BIN-e
93+
rm -f "${TMP_BIN}-e"
9094
fi
9195

9296
$TMP_BIN --upgrade

0 commit comments

Comments
 (0)