This commit is contained in:
@@ -53,4 +53,34 @@ def test_discard_changes_restores_clean_disposable_workspace(tmp_path) -> None:
|
||||
workspace.discard_changes()
|
||||
|
||||
assert tracked.read_text() == "<?php\nreturn [];\n"
|
||||
assert not untracked.exists()
|
||||
assert not untracked.exists()
|
||||
|
||||
|
||||
def test_checkpoint_restores_last_valid_changes(tmp_path) -> None:
|
||||
workspace = GitWorkspace(settings(workspace_root=tmp_path), 4)
|
||||
workspace.path.mkdir()
|
||||
subprocess.run(["git", "init"], cwd=workspace.path, check=True, capture_output=True)
|
||||
subprocess.run(
|
||||
["git", "config", "user.email", "test@example.invalid"],
|
||||
cwd=workspace.path,
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
["git", "config", "user.name", "Test"],
|
||||
cwd=workspace.path,
|
||||
check=True,
|
||||
)
|
||||
tracked = workspace.path / "config.php"
|
||||
tracked.write_text("<?php\nreturn [];\n")
|
||||
subprocess.run(["git", "add", "."], cwd=workspace.path, check=True)
|
||||
subprocess.run(["git", "commit", "-m", "base"], cwd=workspace.path, check=True, capture_output=True)
|
||||
tracked.write_text("<?php\nreturn ['valid'];\n")
|
||||
added = workspace.path / "test.php"
|
||||
added.write_text("<?php\n")
|
||||
checkpoint = workspace.checkpoint()
|
||||
tracked.write_text("<?php\nreturn [broken;\n")
|
||||
|
||||
workspace.restore_checkpoint(checkpoint)
|
||||
|
||||
assert tracked.read_text() == "<?php\nreturn ['valid'];\n"
|
||||
assert added.exists()
|
||||
Reference in New Issue
Block a user