Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

test(signature-store): add unit tests for createSignatureStore and createThoughtBuffer - #551

Merged
giuliovv merged 1 commit into
mainfrom
test/signature-store
Apr 28, 2026
Merged

giuliovv merged 1 commit into
mainfrom
test/signature-store

Conversation

@giuliovv

Copy link
Copy Markdown
Collaborator

Summary

Adds unit tests for createSignatureStore, createThoughtBuffer, and defaultSignatureStore in src/plugin/stores/signature-store.test.ts.

  • createSignatureStore (10 tests) — covers get/set/has/delete CRUD operations, key overwriting, store isolation between instances, empty-string keys, and collision-free storage across 50 keys
  • createThoughtBuffer (8 tests) — covers numeric index get/set, clear (including no-op on empty), overwriting, buffer isolation between instances, and empty-string values
  • defaultSignatureStore (2 tests) — verifies the module-level singleton exposes the full SignatureStore interface and returns the same reference on re-import

…eateThoughtBuffer

Co-Authored-By: Giulio Vaccari <io@giuliovaccari.it>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cac689f7-069b-43f5-a37f-bb21013e4bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 09ccf4b and 8ccbed3.

📒 Files selected for processing (1)
  • src/plugin/stores/signature-store.test.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🔇 Additional comments (3)
src/plugin/stores/signature-store.test.ts (3)

10-76: Strong coverage for createSignatureStore behavior.

This block validates core CRUD semantics, overwrite behavior, instance isolation, empty-string keys, and multi-key storage without collisions in a clear and maintainable way.


80-133: createThoughtBuffer tests are well-scoped and complete for current API.

Good coverage of unset reads, numeric indexing (including 0), overwrite behavior, clear semantics, no-op clear, instance isolation, and empty-string payloads.


137-149: defaultSignatureStore singleton checks look correct.

The assertions cover interface shape and module-cache reference identity via re-import, which matches the module-level singleton contract.


Walkthrough

A new Vitest test file is introduced for validating signature and thought storage functionality. The tests verify that createSignatureStore() correctly handles basic operations (get/set/has/delete), supports overwriting and independent instances, and handles edge cases including empty-string keys and many distinct keys. Tests for createThoughtBuffer() validate indexed storage with operations like clear and overwriting. Additionally, tests confirm that defaultSignatureStore is exported as a singleton-like reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding unit tests for createSignatureStore and createThoughtBuffer functions.
Description check ✅ Passed The description is directly related to the changeset, providing detailed coverage of the test cases added across three exports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new test file (src/plugin/stores/signature-store.test.ts) with 20 unit tests covering createSignatureStore (CRUD + isolation + edge cases), createThoughtBuffer (get/set/clear + isolation + edge cases), and defaultSignatureStore (interface shape + singleton identity). The implementation under test is straightforward Map-backed code, and the tests are well-aligned with the actual interface definitions in types.ts.

Confidence Score: 5/5

This PR is safe to merge — it only adds a new test file with no changes to production code.

All 20 tests correctly match the TypeScript interfaces and the Map-backed implementation. No logic errors, no missing teardown concerns given the singleton tests don't mutate shared state, and the dynamic-import singleton check is valid under Vitest's default module caching within a test file.

No files require special attention.

Important Files Changed

Filename Overview
src/plugin/stores/signature-store.test.ts New test file adding 20 unit tests for signature-store module; tests are correct, well-isolated, and match the TypeScript interfaces in types.ts

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class SignatureStore {
        +get(key: string) SignedThinking | undefined
        +set(key: string, value: SignedThinking) void
        +has(key: string) boolean
        +delete(key: string) void
    }

    class ThoughtBuffer {
        +get(index: number) string | undefined
        +set(index: number, text: string) void
        +clear() void
    }

    class SignedThinking {
        +text: string
        +signature: string
    }

    class createSignatureStore {
        <<factory>>
        returns SignatureStore
    }

    class createThoughtBuffer {
        <<factory>>
        returns ThoughtBuffer
    }

    class defaultSignatureStore {
        <<singleton>>
    }

    createSignatureStore --> SignatureStore
    createThoughtBuffer --> ThoughtBuffer
    SignatureStore --> SignedThinking
    defaultSignatureStore --|> SignatureStore
Loading

Reviews (1): Last reviewed commit: "test(signature-store): add unit tests fo..." | Re-trigger Greptile

@giuliovv
giuliovv merged commit 4f8989f into main Apr 28, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant