Rewrite CLI around action runtime
This commit is contained in:
@@ -9,7 +9,7 @@ import yaml
|
||||
|
||||
from flow.core.config import AppConfig, FlowContext
|
||||
from flow.core.console import Console
|
||||
from flow.core.errors import FlowError
|
||||
from flow.core.errors import FlowError, PlanConflict
|
||||
from flow.core.platform import PlatformInfo
|
||||
from flow.core.runtime import SystemRuntime
|
||||
from flow.core import paths
|
||||
@@ -187,7 +187,7 @@ class TestDotfilesServiceLink:
|
||||
output = capsys.readouterr().out
|
||||
assert "zsh" in output
|
||||
|
||||
def test_relink_does_not_remove_unmanaged_file(self, tmp_path, monkeypatch):
|
||||
def test_relink_fails_on_unmanaged_file(self, tmp_path, monkeypatch):
|
||||
home = tmp_path / "home"
|
||||
home.mkdir()
|
||||
|
||||
@@ -208,7 +208,8 @@ class TestDotfilesServiceLink:
|
||||
target.unlink()
|
||||
target.write_text("user managed file")
|
||||
|
||||
svc.link()
|
||||
with pytest.raises(PlanConflict):
|
||||
svc.link()
|
||||
assert target.read_text() == "user managed file"
|
||||
assert not target.is_symlink()
|
||||
|
||||
@@ -619,12 +620,10 @@ class TestUnclonedModuleWarning:
|
||||
), console.warnings
|
||||
|
||||
|
||||
class TestOrphanAdoption:
|
||||
"""After a partial-failure rerun the planner adopts pre-existing matching
|
||||
symlinks. We simulate a failure during _apply_plan by replacing
|
||||
create_symlink mid-flight, then re-running link()."""
|
||||
class TestActionRollback:
|
||||
"""A mid-execution failure rolls back created links and leaves state absent."""
|
||||
|
||||
def test_partial_apply_failure_recoverable_via_rerun(self, tmp_path, monkeypatch):
|
||||
def test_partial_apply_failure_rolls_back_then_rerun_succeeds(self, tmp_path, monkeypatch):
|
||||
home = tmp_path / "home"
|
||||
home.mkdir()
|
||||
dotfiles = _setup_dotfiles(tmp_path, {
|
||||
@@ -659,13 +658,13 @@ class TestOrphanAdoption:
|
||||
# State file should NOT have been written (atomic semantics: we
|
||||
# only persist when _apply_plan completes).
|
||||
assert not state_path.exists()
|
||||
# First symlink landed on disk.
|
||||
# The first symlink was rolled back.
|
||||
existing_links = sorted(
|
||||
p.name for p in home.rglob("*") if p.is_symlink()
|
||||
)
|
||||
assert len(existing_links) == 1
|
||||
assert existing_links == []
|
||||
|
||||
# Restore real implementation and re-run: orphan adoption kicks in.
|
||||
# Restore real implementation and re-run.
|
||||
monkeypatch.setattr(ctx.runtime.fs, "create_symlink", real_create)
|
||||
svc.link()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user