Skip to content

test: formalize store contract tests (#162 step 4/4)#177

Merged
coji merged 3 commits into
mainfrom
feat/store-contract-tests
Mar 29, 2026
Merged

test: formalize store contract tests (#162 step 4/4)#177
coji merged 3 commits into
mainfrom
feat/store-contract-tests

Conversation

@coji
Copy link
Copy Markdown
Owner

@coji coji commented Mar 29, 2026

Summary

  • Expand storage.shared.ts with comprehensive contract tests for all 21 Store interface methods
  • Coverage: 10/21 methods (48%) → 21/21 (100%)
  • 696 lines of new tests organized by category

Test Categories

Category What's tested
Queue invariants Idempotent trigger, concurrency key exclusion, empty queue
Lease atomicity renewLease/completeRun/failRun with stale generation guards
State transitions Terminal monotonicity, cancelRun, expired lease recovery
Step contract Persist with guard, delete, replay consistency
Batch and cleanup enqueueMany, deleteRun cascade, purgeRuns cutoff
Progress and logs updateProgress, createLog/getLogs round-trip
Edge cases Pagination, filter combinations

Context

Final step (4/4) of #162 (core internal restructuring). Completes the issue.

Test plan

  • pnpm validate passes
  • takt acceptance: all completion criteria met
  • Tests run against both Node and browser dialects
  • CodeRabbit review

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • ストレージ周りの包括的なテストを追加:バッチ投入の成功/アトミックロールバック、リースの延長と陳腐化判定、実行の完了/失敗/キャンセル時の永続化とリース解除、進捗更新のリース整合性検証、期限切れリースの再キュー/競合時失敗処理、実行・ステップ・ログの削除挙動、ログ順序・進捗再生、ページネーション/フィルタ検索、古い終端実行の一括削除検証。

Expand storage.shared.ts with comprehensive contract tests covering
all 21 Store interface methods:

- Queue invariants: idempotent trigger, concurrency key exclusion
- Lease atomicity: renewLease/completeRun/failRun generation guards
- State transitions: terminal monotonicity, cancelRun, expired lease recovery
- Step contract: persist with guard, delete, replay consistency
- Batch and cleanup: enqueueMany, deleteRun cascade, purgeRuns cutoff
- Progress and logs: updateProgress, createLog/getLogs round-trip
- Edge cases: empty queue, pagination, filter combinations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
durably-demo Ready Ready Preview Mar 29, 2026 6:08am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
durably-demo-vercel-turso Ignored Ignored Preview Mar 29, 2026 6:08am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 29, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 52 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 52 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe0bdd28-2d25-41b4-b9cf-158ba54aca54

📥 Commits

Reviewing files that changed from the base of the PR and between d555a77 and 55d2024.

📒 Files selected for processing (1)
  • packages/durably/tests/shared/db-concurrency.shared.ts
📝 Walkthrough

Walkthrough

ストレージのテストスイートが大幅に拡張され、enqueueMany、renewLease、completeRun/failRun、updateProgress、cancelRun、releaseExpiredLeases、deleteRun/deleteSteps、ログ・進捗リプレイ、クエリヘルパー、purgeRuns 等の動作を検証する多数の新規テストが追加されました。

Changes

Cohort / File(s) Summary
Storage API テストスイート拡張
packages/durably/tests/shared/storage.shared.ts
ConflictErrorをインポートに追加。enqueueManyのバッチ永続化と原子ロールバック、renewLeaseの整合性検証、complete/fail/cancel/updateProgressのリーシングガード、releaseExpiredLeasesの再キュー/失敗条件、deleteRun/deleteStepsのクリーンアップ、ログ・進捗リプレイ、getRunsのページネーション/フィルタ、purgeRunsの削除条件など多数のテスト(+688行)を追加。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 テストの庭でホップ、ホップ、ホップ、
バッチもリースもうまくはかるポップ。
競合が来ればぴょんと跳ねて、
ログと進捗を歌にして、
安心して走れ、ランよ、ぴょん!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、変更内容の主要なポイント(Store契約テストの形式化)を明確に要約しており、チェンジセットと完全に関連している。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/store-contract-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Split completeRun/failRun tests into separate it() blocks: one for
  terminal state persistence, one for stale generation rejection
- Replace direct DB queries in deleteRun test with getSteps/getLogs
  (keep labels DB query since no public API exists for label lookup)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The directConcurrentClaim test runs 25 iterations of parallel claim
races with cleanup between each. Under load (CI, PostgreSQL
Testcontainers), this can exceed the default 5s timeout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coji coji merged commit 12c92b2 into main Mar 29, 2026
5 checks passed
@coji coji deleted the feat/store-contract-tests branch March 29, 2026 06:13
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