Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tests/python/test_ghost_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,30 @@ def test_label_may_carry_a_subdirectory(self):
self.assertTrue(os.path.isfile(
os.path.join(self.backup_root, "sub", "state.vscdb")))

def test_existing_destination_is_clobbered(self):
def test_existing_destination_is_uniquified_not_clobbered(self):
# 4f308f8 changed the contract: an existing same-label destination is
# NEVER overwritten (that destroyed pristine pre-run copies); the new
# backup uniquifies with a -2 suffix instead. The old copy must
# survive untouched and the report must point at the unique path.
dst = os.path.join(self.backup_root, "state.vscdb")
os.makedirs(self.backup_root, exist_ok=True)
with open(dst, "wb") as f:
f.write(b"stale-backup-bytes")
r = backup.backup_to_timestamped_dir(
self.src_file, self.backup_root, "state.vscdb")
self.assertTrue(r["ok"], r)
self.assertEqual(r["destination"], dst + "-2")
with open(dst, "rb") as f:
self.assertEqual(f.read(), b"stale-backup-bytes")
with open(dst + "-2", "rb") as f:
self.assertEqual(f.read(), b"sqlite-bytes" * 64)
# A third run keeps walking the suffix chain (-3), never touching -1.
r2 = backup.backup_to_timestamped_dir(
self.src_file, self.backup_root, "state.vscdb")
self.assertTrue(r2["ok"], r2)
self.assertEqual(r2["destination"], dst + "-3")
with open(dst, "rb") as f:
self.assertEqual(f.read(), b"stale-backup-bytes")

def test_transient_lock_retries_then_succeeds(self):
calls = []
Expand Down
Loading