test(worker): Durable Object layer tests via vitest-pool-workers (patch)#226
Merged
Conversation
Add Miniflare-backed tests for the two SQLite Durable Objects (WebhookStore, TenantRegistry) that cannot run under the existing tsx --test harness because they depend on ctx.storage.sql. Introduce @cloudflare/vitest-pool-workers scoped only to these DO tests; the existing tsx pure-logic/oauth suite is left untouched. New test/workers/store.test.ts and test/workers/tenant.test.ts drive each DO through its fetch routes (HTTP-style, not public methods), using a unique idFromName per test for storage isolation. test-do-entry.ts re-exports only the two DO classes so the full worker graph and OAuth KV are never bound. The @cloudflare/workers-types pin + overrides block prevents a transitive bump from breaking existing src types. The test script chains both suites. tsx --test glob stays top-level (test/*.test.ts) so it does not pick up the new test/workers/ files; the vitest workers config includes test/workers/**/*.test.ts. 二つの SQLite Durable Object は ctx.storage.sql に依存し既存ハーネスで動かせないため、 DO テストに限定して vitest-pool-workers を導入した。 Refs #225
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-webhook-mcp | 5ee8475 | Jun 21 2026, 04:43 AM |
liplus-lin-lay
commented
Jun 21, 2026
liplus-lin-lay
left a comment
Member
Author
There was a problem hiding this comment.
AI self-review (auto mode / 引き継ぎセッション)
前セッションが PR 作成+CI green で停止していたため引き継ぎ。self-review を実施。
コード
- 純テスト追加(7ファイル)。
worker/src/*.tsのロジック変更なし、新規test-do-entry.tsは DO 2クラスの最小 re-export のみ。 - WebhookStore: ingest 冪等性(INSERT OR REPLACE) / pending-status 集計 / pending-events newest-first・limit・processed 除外 / webhook-events full payload / event 404・400 / mark-processed をカバー。
- TenantRegistry: installation resolve・created・deleted(has_other 判定) / quota-check の 429 ゲート+atomic increment / increment over_limit / decrement 0クランプ / unknown route をカバー。
workers-typesピン留め+overrides($ref)は姉妹リポ github-rag-mcp で実証済みの型 bump 地雷対策と同手法。test-env.d.tsの手書き ambient 宣言も同方針で整合。
分類
- patch 妥当。ユーザー/システム観測可能なランタイム変更なし(テスト基盤+テストのみ)。
ゲート
- issue #225 が予約していた「新インフラ導入の Master 確認」ゲートについて Master の承認(go-sign)を取得済み。導入是非クリア。
CI
- CI / test / Workers Builds 3本 pass。tsx 47 + vitest workers 25 = 72本 green、wrangler dry-run 通過。
→ approve 相当。squash merge へ。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #225
概要
#223/#224 で純ロジック層をカバーした続き。残っていた Durable Object 層(
store.ts/tenant.ts、ctx.storage.sql使用)を@cloudflare/vitest-pool-workers(Miniflare) で本格的にテストする。実証済みの姉妹リポジトリgithub-rag-mcpのパターンを移植した。影響スコープ
worker/src/*.tsのロジック変更なし(新規test-do-entry.tsのみ追加)。変更
ハーネス方針
既存の tsx --test(47本)は無変更で温存、DO テストは test/workers/ 配下に分離。npm test = tsx --test test/*.test.ts && vitest run --config vitest.workers.config.ts。workers-types のピン留めは vitest-pool-workers の型 bump 地雷対策(rag-mcp と同手法)。
確認