Skip to content

Add unit tests for WorkersKvStore - #987

Open
kecan0406 wants to merge 1 commit into
fedify-dev:mainfrom
kecan0406:cfworkers-kv-tests
Open

Add unit tests for WorkersKvStore#987
kecan0406 wants to merge 1 commit into
fedify-dev:mainfrom
kecan0406:cfworkers-kv-tests

Conversation

@kecan0406

Copy link
Copy Markdown

Test get(), set(), and delete(), TTL clamping with expiration metadata, and prefix listing over JSON-encoded keys using an in-memory mock of the Workers KV namespace.
The file runs under Vitest, so it is excluded from deno test in packages/cfworkers/deno.json.

Closes #874 Closes #875

Changelog: none
Assisted-by: Claude Code:claude-fable-5

Test get(), set(), and delete(), TTL clamping with expiration
metadata, and prefix listing over JSON-encoded keys using an in-memory
mock of the Workers KV namespace.  The file runs under Vitest, so it
is excluded from deno test in packages/cfworkers/deno.json.

Closes fedify-dev#874
Closes fedify-dev#875

Changelog: none
Assisted-by: Claude Code:claude-fable-5
@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit 362459a
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a76a2de2f60db00087ca187

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5640dfe4-dcde-4986-9ce0-93384949e629

📥 Commits

Reviewing files that changed from the base of the PR and between 15ad151 and 362459a.

📒 Files selected for processing (2)
  • packages/cfworkers/deno.json
  • packages/cfworkers/src/mod.test.ts

📝 Walkthrough

Walkthrough

The pull request adds Deno test exclusion configuration and comprehensive Vitest coverage for WorkersKvStore. The tests use Cloudflare KV and Temporal mocks to validate CRUD operations, expiration, TTL handling, prefix listing, and cursor pagination.

Changes

Workers KV test coverage

Layer / File(s) Summary
KV storage and expiration behavior
packages/cfworkers/src/mod.test.ts, packages/cfworkers/deno.json
Adds Cloudflare KV and Temporal mocks. Tests cover JSON serialization, CRUD operations, missing keys, expiration filtering, and TTL handling. Deno excludes Vitest files from test discovery.
KV listing and pagination
packages/cfworkers/src/mod.test.ts
Tests exact-prefix matching, sibling-prefix exclusion, expired-entry filtering, returned values, and cursor-based pagination.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Issue 876: The tests cover expired-entry filtering in WorkersKvStore.get() and list().

Suggested reviewers: 2chanhaeng, dahlia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding unit tests for WorkersKvStore.
Description check ✅ Passed The description accurately summarizes the WorkersKvStore tests, mock KV namespace, Vitest configuration, and linked issues.
Linked Issues check ✅ Passed The PR adds the requested in-memory KV mock and tests for WorkersKvStore get(), set(), and delete() in the specified file.
Out of Scope Changes check ✅ Passed The test coverage and Deno test-discovery configuration support the stated testing objective and contain no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit 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.

@2chanhaeng 2chanhaeng left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

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.

Test prefix listing in @fedify/cfworkers KV Add basic KV tests for @fedify/cfworkers

2 participants