Skip to content

Commit e8dce4f

Browse files
test(utils): pin both tied backup paths on the tie error
CodeRabbit's pre-merge walkthrough named lines 232-234 of the recovery spec: the two error properties were only checked to contain the directory, and nothing pinned that the message names the two backups it refused to choose between. The set comparison replaces the two toContain(dir) rows so the assertion holds whatever order readdir handed the tied pair in, and the two basename rows are the only rows that fail when the basenames drop out of the message. Production content is unchanged, so the counted-executable-line price does not move: 26 counted lines and 3 selectors against merge base d3d9cd4. Controls: pointing secondBackupPath at the first tied path fails the set row (exit 1, 1 failed / 14 passed); replacing both basenames in the message with a fixed phrase fails exactly the two basename rows (exit 1, 2 failed / 13 passed); restoring the production blob gives 15 passed (exit 0). Co-Authored-By: Claude <[email protected]>
1 parent 7f4a40a commit e8dce4f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/utils/__tests__/jsonFileRecovery.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ describe("reader recovery", () => {
230230
expect(tie.message).toContain("history_item.json")
231231
expect(tie.message).toContain("share mtime 1700000000000")
232232
expect(tie.targetPath).toBe(target)
233-
expect(tie.firstBackupPath).toContain(dir)
234-
expect(tie.secondBackupPath).toContain(dir)
233+
// The two tied files, whatever order readdir handed them in: the guard reports both,
234+
// and which one lands on which property is not something the caller can rely on.
235+
expect([tie.firstBackupPath, tie.secondBackupPath].sort()).toEqual([backup, otherBackup].sort())
236+
expect(tie.message).toContain(path.basename(backup))
237+
expect(tie.message).toContain(path.basename(otherBackup))
235238
})
236239
})

0 commit comments

Comments
 (0)