44
55TMP_DIR=" tmp"
66TMP_BIN=" $TMP_DIR /bashunit"
7- ACTIVE_INTERNET=0
7+ ACTIVE_INTERNET=false
8+ HAS_DOWNLOADER=false
9+ HAS_GIT=false
810
911function set_up_before_script() {
10- env::active_internet_connection
11- ACTIVE_INTERNET=$?
12+ if env::active_internet_connection; then
13+ ACTIVE_INTERNET=true
14+ fi
15+
16+ if dependencies::has_curl || dependencies::has_wget; then
17+ HAS_DOWNLOADER=true
18+ fi
19+
20+ if dependencies::has_git; then
21+ HAS_GIT=true
22+ fi
1223}
1324
1425function tear_down_after_script() {
@@ -17,7 +28,11 @@ function tear_down_after_script() {
1728
1829function set_up() {
1930 ./build.sh " $TMP_DIR " > /dev/null
20- LATEST_VERSION=" $( helpers::get_latest_tag) "
31+ if [[ " $ACTIVE_INTERNET " == true ]] && [[ " $HAS_GIT " == true ]]; then
32+ LATEST_VERSION=" $( helpers::get_latest_tag) "
33+ else
34+ LATEST_VERSION=" ${BASHUNIT_VERSION} "
35+ fi
2136 TEST_ENV_FILE=" tests/acceptance/fixtures/.env.default"
2237}
2338
@@ -36,9 +51,15 @@ function test_do_not_upgrade_when_latest() {
3651}
3752
3853function test_upgrade_when_a_new_version_found() {
39- if [[ " $ACTIVE_INTERNET " -eq 1 ]]; then
54+ if [[ " $ACTIVE_INTERNET " == false ]]; then
4055 skip " no internet connection" && return
4156 fi
57+ if [[ " $HAS_GIT " == false ]]; then
58+ skip " git not installed" && return
59+ fi
60+ if [[ " $HAS_DOWNLOADER " == false ]]; then
61+ skip " curl or wget not installed" && return
62+ fi
4263
4364 sed -i -e \
4465 ' s/declare -r BASHUNIT_VERSION="[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}"/declare -r BASHUNIT_VERSION="0.1.0"/' \
@@ -57,16 +78,22 @@ function test_upgrade_when_a_new_version_found() {
5778}
5879
5980function test_do_not_update_on_consecutive_calls() {
60- if [[ " $ACTIVE_INTERNET " -eq 1 ]]; then
81+ if [[ " $ACTIVE_INTERNET " == false ]]; then
6182 skip " no internet connection" && return
6283 fi
84+ if [[ " $HAS_GIT " == false ]]; then
85+ skip " git not installed" && return
86+ fi
87+ if [[ " $HAS_DOWNLOADER " == false ]]; then
88+ skip " curl or wget not installed" && return
89+ fi
6390
6491 sed -i -e \
6592 ' s/declare -r BASHUNIT_VERSION="[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}"/declare -r BASHUNIT_VERSION="0.1.0"/' \
66- $TMP_BIN
93+ " $TMP_BIN "
6794
6895 if [[ $_OS == " OSX" ]]; then
69- rm $ TMP_BIN-e
96+ rm -f " ${ TMP_BIN} -e "
7097 fi
7198
7299 $TMP_BIN --upgrade
0 commit comments