Skip to content

Commit 467bb02

Browse files
committed
Merge branch 'main' into fix-test-doubles
Conflicts: tests/functional/fixtures/doubles_function.sh tests/functional/fixtures/doubles_script.sh
2 parents 0134264 + 0ef406d commit 467bb02

7 files changed

Lines changed: 53 additions & 2 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ report.html
1818

1919
# internal
2020
local/
21+
tmp/
2122
dev.log

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function build_and_install_beta() {
2424
exit 1
2525
fi
2626

27-
git clone --depth 1 --no-tags $BASHUNIT_GIT_REPO temp_bashunit 2>/dev/null
27+
git clone --depth 1 --no-tags "$BASHUNIT_GIT_REPO" temp_bashunit 2>/dev/null
2828
cd temp_bashunit
2929
./build.sh >/dev/null
3030
local latest_commit=$(git rev-parse --short=7 HEAD)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
firefox 2.0
2+
Xorg 1.6
3+
jetbrains-toolbox 1.3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
firefox 2.0
2+
Xorg 1.6
3+
jetbrains-toolbox 1.3

tests/unit/console_results_test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ function test_render_execution_time_on_osx_without_perl() {
297297
mock dependencies::has_perl mock_false
298298

299299
_START_TIME=1727771758.0664479733
300-
EPOCHREALTIME=1727780556.4266040325
301300

302301
local render_result
303302
render_result=$(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
function function_to_be_spied_on(){
4+
echo "this function should be spy and not execute"
5+
}

tests/unit/test_doubles_test.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,43 @@ function test_unsuccessful_spy_called_times() {
6565
"$(console_results::print_failed_test "Unsuccessful spy called times" "ps" "to has been called" "1 times")"\
6666
"$(assert_have_been_called_times 1 ps)"
6767
}
68+
69+
function test_successful_spy_with_source_function() {
70+
# shellcheck source=/dev/null
71+
source ./fixtures/fake_function_to_spy.sh
72+
spy function_to_be_spied_on
73+
74+
function_to_be_spied_on
75+
76+
assert_have_been_called function_to_be_spied_on
77+
}
78+
79+
function test_unsuccessful_spy_with_source_function_have_been_called() {
80+
# shellcheck source=/dev/null
81+
source ./fixtures/fake_function_to_spy.sh
82+
spy function_to_be_spied_on
83+
84+
function_to_be_spied_on
85+
function_to_be_spied_on
86+
87+
assert_same\
88+
"$(console_results::print_failed_test \
89+
"Unsuccessful spy with source function have been called"\
90+
"function_to_be_spied_on" \
91+
"to has been called" \
92+
"1 times")"\
93+
"$(assert_have_been_called_times 1 function_to_be_spied_on)"
94+
}
95+
96+
97+
function test_successful_spy_called_times_with_source() {
98+
# shellcheck source=/dev/null
99+
source ./fixtures/fake_function_to_spy.sh
100+
spy function_to_be_spied_on
101+
102+
function_to_be_spied_on
103+
function_to_be_spied_on
104+
105+
assert_have_been_called_times 2 function_to_be_spied_on
106+
}
107+

0 commit comments

Comments
 (0)