bashunit
bashunit copied to clipboard
Is there assert_have_been_called_with for mocks?
Hi,
I have this and it doesnt work. Is this supported?
mock create_remote_time_entries "echo 'Date range: 2025-03-29 to 2025-03-29'"
result="$(run)"
assert_have_been_called_with 'create_remote_time_entries' '2023-10-01'
Hi @filisko , thanks for your feedback!
Unfortunately, test doubles assertions work only within the same process, so when you spawn a new process (like $(run)) then the test doubles (spys and mocks) are not working as you might expect.
I understand this is a very useful feature. I tried some weeks ago to find a fix this this, but I couldn't find one... I will try again (some day in the future) to see if I can end-up with a possible working-solution, but for now there is no work around (I couldn't find one...).
Feel free to try finding out a solution for this very exciting problem. PRs welcome! 🚀