mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Add changelog and test case
This commit is contained in:
parent
2e467c16e8
commit
a3619a41fb
3 changed files with 50 additions and 4 deletions
1
changelog/62480.added
Normal file
1
changelog/62480.added
Normal file
|
@ -0,0 +1 @@
|
|||
Added debug log messages displaying the command being run when installing packages on Windows
|
|
@ -1768,10 +1768,10 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
|
|||
|
||||
# Install the software
|
||||
# Check Use Scheduler Option
|
||||
log.debug("PKG : cmd: %s /s /c %s", cmd_shell, arguments)
|
||||
log.debug("PKG : pwd: %s", cache_path)
|
||||
if pkginfo[version_num].get("use_scheduler", False):
|
||||
# Create Scheduled Task
|
||||
log.debug("PKG : cmd: %s /s /c %s", cmd_shell, arguments)
|
||||
log.debug("PKG : pwd: %s", cache_path)
|
||||
__salt__["task.create_task"](
|
||||
name="update-salt-software",
|
||||
user_name="System",
|
||||
|
@ -1829,8 +1829,6 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
|
|||
ret[pkg_name] = {"install status": "failed"}
|
||||
else:
|
||||
# Launch the command
|
||||
log.debug("PKG : cmd: %s /s /c %s", cmd_shell, arguments)
|
||||
log.debug("PKG : pwd: %s", cache_path)
|
||||
result = __salt__["cmd.run_all"](
|
||||
'"{}" /s /c "{}"'.format(cmd_shell, arguments),
|
||||
cache_path,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""
|
||||
Tests for the win_pkg module
|
||||
"""
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.modules.config as config
|
||||
|
@ -279,6 +281,51 @@ def test_pkg_install_single_pkg():
|
|||
assert "-e True -test_flag True" in str(mock_cmd_run_all.call_args[0])
|
||||
|
||||
|
||||
def test_pkg_install_log_message(caplog):
|
||||
"""
|
||||
test pkg.install pkg with extra_install_flags
|
||||
"""
|
||||
ret__get_package_info = {
|
||||
"3.03": {
|
||||
"uninstaller": "%program.exe",
|
||||
"reboot": False,
|
||||
"msiexec": False,
|
||||
"installer": "runme.exe",
|
||||
"uninstall_flags": "/S",
|
||||
"locale": "en_US",
|
||||
"install_flags": "/s",
|
||||
"full_name": "Firebox 3.03 (x86 en-US)",
|
||||
}
|
||||
}
|
||||
|
||||
mock_cmd_run_all = MagicMock(return_value={"retcode": 0})
|
||||
with patch.object(
|
||||
salt.utils.data, "is_true", MagicMock(return_value=True)
|
||||
), patch.object(
|
||||
win_pkg, "_get_package_info", MagicMock(return_value=ret__get_package_info)
|
||||
), patch.dict(
|
||||
win_pkg.__salt__,
|
||||
{
|
||||
"pkg_resource.parse_targets": MagicMock(
|
||||
return_value=[{"firebox": "3.03"}, None]
|
||||
),
|
||||
"cp.is_cached": MagicMock(return_value="C:\\fake\\path.exe"),
|
||||
"cmd.run_all": mock_cmd_run_all,
|
||||
},
|
||||
), caplog.at_level(logging.DEBUG):
|
||||
win_pkg.install(
|
||||
pkgs=["firebox"],
|
||||
version="3.03",
|
||||
extra_install_flags="-e True -test_flag True",
|
||||
)
|
||||
assert (
|
||||
'PKG : cmd: C:\\WINDOWS\\system32\\cmd.exe /s /c "runme.exe" /s -e '
|
||||
"True -test_flag True"
|
||||
) in caplog.messages
|
||||
assert "PKG : pwd: " in caplog.messages
|
||||
assert "PKG : retcode: 0" in caplog.messages
|
||||
|
||||
|
||||
def test_pkg_install_multiple_pkgs():
|
||||
"""
|
||||
test pkg.install pkg with extra_install_flags
|
||||
|
|
Loading…
Add table
Reference in a new issue