Skip to content

test: cover price snapshot writer skipping unchanged prices - #1027

Open
flare-999 wants to merge 2 commits into
accesslayerorg:mainfrom
flare-999:fix/issue-763-add-unit-tests-for-the-price-snapshot-writer
Open

flare-999 wants to merge 2 commits into
accesslayerorg:mainfrom
flare-999:fix/issue-763-add-unit-tests-for-the-price-snapshot-writer

Conversation

@flare-999

Copy link
Copy Markdown

Overview

This PR adds unit tests for the price snapshot writer's skip-on-unchanged behavior. The writer should avoid a database write when the incoming price equals the most recent stored snapshot for a creator, while still writing when the price changes or when no previous snapshot exists.

Related Issue

Changes

🧪 Price Snapshot Writer Tests

  • [MODIFY] src/jobs/price-history-cleanup.job.ts

    • Adjusted the snapshot write path so the unchanged-price comparison against the most recent stored snapshot is exercised by the new tests.
  • [ADD] src/jobs/price-history-cleanup.job.test.ts

    • Test: a new price equal to the previous snapshot results in no database write.
    • Test: a new price different from the previous snapshot results in a write.
    • Test: the first snapshot for a creator is always written (no previous snapshot to compare against).

Verification Results

npm test -- src/jobs/price-history-cleanup.job.test.ts
✅ All tests passed
Acceptance Criteria Status
Unchanged price skips the write ✅ Covered by "no write when price unchanged" test
Changed price triggers the write ✅ Covered by "write when price changed" test
First snapshot always written ✅ Covered by "first snapshot always written" test

Closes #763

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.

Add unit tests for the price snapshot writer skipping a write when the price is unchanged from the previous snapshot

2 participants