Skip to content

Fail when a sample note drifts from the cache snapshot - #80

Merged
rcasazza merged 1 commit into
mainfrom
test/sample-notes-match-snapshot
Nov 25, 2026
Merged

rcasazza merged 1 commit into
mainfrom
test/sample-notes-match-snapshot

Conversation

@rcasazza

Copy link
Copy Markdown
Member

What changed

  • A new test in tests/obsidian-cache.test.ts compares the notes in test-vault/Cache samples/ with tests/fixtures/obsidian-cache.json. It fails if a note was added, removed or changed since the snapshot, and its message points to the recapture steps.
  • tests/fixtures/README.md says that npm test fails until you recapture.

Why

The real-cache and write-back tests read note text from the snapshot, not from the vault. A sample note edited without recapturing would leave every test passing against the old text, while the note and the fixture quietly drift apart.

Checked

  • With the notes as committed, the test passes. That also confirms the files on disk match the snapshot byte for byte, CRLF line endings included.
  • Adding a line to markers.md fails with "markers.md changed since the snapshot…".
  • Adding a new.md fails with "sample notes were added or removed…".
  • npm run build, npm run lint and npm test pass (2,495 tests).

Tests only; nothing changes for users.

🤖 Generated with Claude Code

The real-cache tests read note text from obsidian-cache.json, so a sample
note edited, added or removed without recapturing would leave them checking
old text and still passing. Compare the notes in test-vault/Cache samples/
with the snapshot and point to the recapture steps when they differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rcasazza
rcasazza merged commit bfbd796 into main Nov 25, 2026
2 checks passed
@rcasazza
rcasazza deleted the test/sample-notes-match-snapshot branch November 25, 2026 12:26
@rcasazza rcasazza mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant