mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add tests and changelog
This commit is contained in:
parent
26e31d23d5
commit
572e955388
2 changed files with 92 additions and 0 deletions
3
changelog/64630.fixed.md
Normal file
3
changelog/64630.fixed.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Fixed an intermittent issue with file.recurse where the state would
|
||||||
|
report failure even on success. Makes sure symlinks are created
|
||||||
|
after the target file is created
|
|
@ -7,6 +7,19 @@ pytestmark = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def symlink(state_tree):
|
||||||
|
# Create directory structure
|
||||||
|
source_dir = state_tree / "test_symlink"
|
||||||
|
if not source_dir.is_dir():
|
||||||
|
source_dir.mkdir()
|
||||||
|
source_file = source_dir / "source_file.txt"
|
||||||
|
source_file.write_text("This is the source file...")
|
||||||
|
symlink_file = source_dir / "symlink"
|
||||||
|
symlink_file.symlink_to(source_file)
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test", (False, True))
|
@pytest.mark.parametrize("test", (False, True))
|
||||||
def test_recurse(file, tmp_path, grail, test):
|
def test_recurse(file, tmp_path, grail, test):
|
||||||
"""
|
"""
|
||||||
|
@ -249,3 +262,79 @@ def test_issue_2726_mode_kwarg(modules, tmp_path, state_tree):
|
||||||
ret = modules.state.template_str("\n".join(good_template))
|
ret = modules.state.template_str("\n".join(good_template))
|
||||||
for state_run in ret:
|
for state_run in ret:
|
||||||
assert state_run.result is True
|
assert state_run.result is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue_64630_keep_symlinks_true(file, symlink, tmp_path):
|
||||||
|
"""
|
||||||
|
Make sure that symlinks are created and that there isn't an error
|
||||||
|
"""
|
||||||
|
target_dir = tmp_path / "test_symlink" # Target for the file.recurse state
|
||||||
|
target_file = target_dir / "source_file.txt"
|
||||||
|
target_symlink = target_dir / "symlink"
|
||||||
|
|
||||||
|
ret = file.recurse(
|
||||||
|
name=str(target_dir), source=f"salt://{target_dir.name}", keep_symlinks=True
|
||||||
|
)
|
||||||
|
assert ret.result is True
|
||||||
|
|
||||||
|
assert target_dir.exists()
|
||||||
|
assert target_file.is_file()
|
||||||
|
assert target_symlink.is_symlink()
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue_64630_keep_symlinks_false(file, symlink, tmp_path):
|
||||||
|
"""
|
||||||
|
Make sure that symlinks are created and that there isn't an error
|
||||||
|
"""
|
||||||
|
target_dir = tmp_path / "test_symlink" # Target for the file.recurse state
|
||||||
|
target_file = target_dir / "source_file.txt"
|
||||||
|
target_symlink = target_dir / "symlink"
|
||||||
|
|
||||||
|
ret = file.recurse(
|
||||||
|
name=str(target_dir), source=f"salt://{target_dir.name}", keep_symlinks=False
|
||||||
|
)
|
||||||
|
assert ret.result is True
|
||||||
|
|
||||||
|
assert target_dir.exists()
|
||||||
|
assert target_file.is_file()
|
||||||
|
assert target_symlink.is_file()
|
||||||
|
assert target_file.read_text() == target_symlink.read_text()
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue_64630_force_symlinks_true(file, symlink, tmp_path):
|
||||||
|
"""
|
||||||
|
Make sure that symlinks are created and that there isn't an error
|
||||||
|
"""
|
||||||
|
target_dir = tmp_path / "test_symlink" # Target for the file.recurse state
|
||||||
|
target_file = target_dir / "source_file.txt"
|
||||||
|
target_symlink = target_dir / "symlink"
|
||||||
|
|
||||||
|
ret = file.recurse(
|
||||||
|
name=str(target_dir), source=f"salt://{target_dir.name}", force_symlinks=True
|
||||||
|
)
|
||||||
|
assert ret.result is True
|
||||||
|
|
||||||
|
assert target_dir.exists()
|
||||||
|
assert target_file.is_file()
|
||||||
|
assert target_symlink.is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue_64630_force_symlinks_keep_symlinks_true(file, symlink, tmp_path):
|
||||||
|
"""
|
||||||
|
Make sure that symlinks are created and that there isn't an error
|
||||||
|
"""
|
||||||
|
target_dir = tmp_path / "test_symlink" # Target for the file.recurse state
|
||||||
|
target_file = target_dir / "source_file.txt"
|
||||||
|
target_symlink = target_dir / "symlink"
|
||||||
|
|
||||||
|
ret = file.recurse(
|
||||||
|
name=str(target_dir),
|
||||||
|
source=f"salt://{target_dir.name}",
|
||||||
|
force_symlinks=True,
|
||||||
|
keep_symlinks=True,
|
||||||
|
)
|
||||||
|
assert ret.result is True
|
||||||
|
|
||||||
|
assert target_dir.exists()
|
||||||
|
assert target_file.is_file()
|
||||||
|
assert target_symlink.is_symlink()
|
||||||
|
|
Loading…
Add table
Reference in a new issue