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

Signed-off-by: Antonio Ramón Sánchez Morales <antonioramonsm@gmail.com>
This commit is contained in:
Antonio Ramón Sánchez Morales 2023-06-30 04:00:15 +02:00 committed by Megan Wilhite
parent 2199d8503b
commit 4ac4da9aa4

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