Skip to content

Commit

Permalink
Merge branch 'main' into fix-test-doubles
Browse files Browse the repository at this point in the history
 Conflicts:
	tests/functional/fixtures/doubles_function.sh
	tests/functional/fixtures/doubles_script.sh
  • Loading branch information
Chemaclass committed Oct 18, 2024
2 parents 0134264 + 0ef406d commit 467bb02
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ report.html

# internal
local/
tmp/
dev.log
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function build_and_install_beta() {
exit 1
fi

git clone --depth 1 --no-tags $BASHUNIT_GIT_REPO temp_bashunit 2>/dev/null
git clone --depth 1 --no-tags "$BASHUNIT_GIT_REPO" temp_bashunit 2>/dev/null
cd temp_bashunit
./build.sh >/dev/null
local latest_commit=$(git rev-parse --short=7 HEAD)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
firefox 2.0
Xorg 1.6
jetbrains-toolbox 1.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
firefox 2.0
Xorg 1.6
jetbrains-toolbox 1.3
1 change: 0 additions & 1 deletion tests/unit/console_results_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ function test_render_execution_time_on_osx_without_perl() {
mock dependencies::has_perl mock_false

_START_TIME=1727771758.0664479733
EPOCHREALTIME=1727780556.4266040325

local render_result
render_result=$(
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/fixtures/fake_function_to_spy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

function function_to_be_spied_on(){
echo "this function should be spy and not execute"
}
40 changes: 40 additions & 0 deletions tests/unit/test_doubles_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,43 @@ function test_unsuccessful_spy_called_times() {
"$(console_results::print_failed_test "Unsuccessful spy called times" "ps" "to has been called" "1 times")"\
"$(assert_have_been_called_times 1 ps)"
}

function test_successful_spy_with_source_function() {
# shellcheck source=/dev/null
source ./fixtures/fake_function_to_spy.sh
spy function_to_be_spied_on

function_to_be_spied_on

assert_have_been_called function_to_be_spied_on
}

function test_unsuccessful_spy_with_source_function_have_been_called() {
# shellcheck source=/dev/null
source ./fixtures/fake_function_to_spy.sh
spy function_to_be_spied_on

function_to_be_spied_on
function_to_be_spied_on

assert_same\
"$(console_results::print_failed_test \
"Unsuccessful spy with source function have been called"\
"function_to_be_spied_on" \
"to has been called" \
"1 times")"\
"$(assert_have_been_called_times 1 function_to_be_spied_on)"
}


function test_successful_spy_called_times_with_source() {
# shellcheck source=/dev/null
source ./fixtures/fake_function_to_spy.sh
spy function_to_be_spied_on

function_to_be_spied_on
function_to_be_spied_on

assert_have_been_called_times 2 function_to_be_spied_on
}

0 comments on commit 467bb02

Please sign in to comment.