finalized for publication
This commit is contained in:
parent
df1f387795
commit
7d51de1052
4 changed files with 626 additions and 392 deletions
|
|
@ -122,3 +122,43 @@ last_switch = ""
|
|||
backups = list(backup_dir.iterdir())
|
||||
assert backups, "expected a backup of inventory.toml to be created"
|
||||
assert any(path.name.startswith("inventory.toml.") for path in backups)
|
||||
|
||||
def test_reset_previous_config(tmp_path: Path, monkeypatch) -> None:
|
||||
rollback = tmp_path / "inventory.toml.rollback"
|
||||
rollback.write_text("prev")
|
||||
|
||||
def fake_get_paths():
|
||||
return tmp_path, tmp_path / "inventory.toml", tmp_path / "inventory.toml.last", rollback
|
||||
|
||||
monkeypatch.setattr(cli, "get_paths", fake_get_paths)
|
||||
cli.reset_previous_config()
|
||||
assert not rollback.exists()
|
||||
|
||||
|
||||
def test_update_section_entries_rewrites_section(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "inventory.toml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
[dnf]
|
||||
git
|
||||
|
||||
[copr]
|
||||
copr.fedorainfracloud.org/user/repo
|
||||
|
||||
[brew]
|
||||
wget
|
||||
""".strip()
|
||||
)
|
||||
|
||||
cli.update_section_entries(config_path, "dnf", ["vim", "curl", "vim"])
|
||||
cli.update_section_entries(config_path, "copr", ["copr.fedorainfracloud.org/user/repo", "copr.fedorainfracloud.org/another/repo"])
|
||||
|
||||
content = config_path.read_text().strip().splitlines()
|
||||
dnf_index = content.index("[dnf]")
|
||||
assert content[dnf_index + 1 : dnf_index + 3] == ["curl", "vim"]
|
||||
assert "[copr]" in content
|
||||
copr_index = content.index("[copr]")
|
||||
assert content[copr_index + 1 : copr_index + 3] == [
|
||||
"copr.fedorainfracloud.org/another/repo",
|
||||
"copr.fedorainfracloud.org/user/repo",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue