mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix unit test on Linux
This commit is contained in:
parent
554da0c21e
commit
a5c3c18442
2 changed files with 10 additions and 4 deletions
|
@ -568,7 +568,7 @@ def _gen_recurse_managed_files(
|
|||
for file_dest, file_src in managed_files:
|
||||
# We need to convert relpath to fullpath. We're using pathlib to
|
||||
# be platform-agnostic
|
||||
symlink_full_path = pathlib.Path(f"{name}\\{link_src_relpath}")
|
||||
symlink_full_path = pathlib.Path(f"{name}{os.sep}{link_src_relpath}")
|
||||
file_dest_full_path = pathlib.Path(file_dest)
|
||||
if symlink_full_path == file_dest_full_path:
|
||||
new_managed_files.append(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
@ -18,7 +19,7 @@ def test__gen_recurse_managed_files():
|
|||
"""
|
||||
Test _gen_recurse_managed_files to make sure it puts symlinks at the end of the list of files.
|
||||
"""
|
||||
target_dir = pathlib.Path("\\some\\path\\target")
|
||||
target_dir = pathlib.Path(f"{os.sep}some{os.sep}path{os.sep}target")
|
||||
cp_list_master = MagicMock(
|
||||
return_value=[
|
||||
"target/symlink",
|
||||
|
@ -28,7 +29,9 @@ def test__gen_recurse_managed_files():
|
|||
],
|
||||
)
|
||||
cp_list_master_symlinks = MagicMock(
|
||||
return_value={"target/symlink": f"{target_dir}\\not_a_symlink\\symlink"}
|
||||
return_value={
|
||||
"target/symlink": f"{target_dir}{os.sep}not_a_symlink{os.sep}symlink"
|
||||
}
|
||||
)
|
||||
patch_salt = {
|
||||
"cp.list_master": cp_list_master,
|
||||
|
@ -38,5 +41,8 @@ def test__gen_recurse_managed_files():
|
|||
files, dirs, links, keep = filestate._gen_recurse_managed_files(
|
||||
name=str(target_dir), source=f"salt://{target_dir.name}", keep_symlinks=True
|
||||
)
|
||||
expected = ("\\some\\path\\target\\symlink", "salt://target/symlink?saltenv=base")
|
||||
expected = (
|
||||
f"{os.sep}some{os.sep}path{os.sep}target{os.sep}symlink",
|
||||
"salt://target/symlink?saltenv=base",
|
||||
)
|
||||
assert files[-1] == expected
|
||||
|
|
Loading…
Add table
Reference in a new issue