fix(test_mac_brew_pkg): adapt test to also mock path.which

Signed-off-by: Antonio Ramón Sánchez Morales <antonioramonsm@gmail.com>
(cherry picked from commit 4ac4da9aa4)
This commit is contained in:
Antonio Ramón Sánchez Morales 2023-06-30 04:00:15 +02:00 committed by Pedro Algarvio
parent 0fda648663
commit 33310ac37d

View file

@ -440,8 +440,9 @@ def test_homebrew_bin(HOMEBREW_BIN):
Tests the path to the homebrew binary
"""
mock_path = MagicMock(return_value="/usr/local")
with patch.dict(mac_brew.__salt__, {"cmd.run": mock_path}):
assert mac_brew._homebrew_bin() == HOMEBREW_BIN
with patch("salt.utils.path.which", MagicMock(return_value=HOMEBREW_BIN)):
with patch.dict(mac_brew.__salt__, {"cmd.run": mock_path}):
assert mac_brew._homebrew_bin() == HOMEBREW_BIN
# 'list_pkgs' function tests: 2