Skip to content

Add unit tests for ScratchpadPlugin #114

Description

@fuseraft

ScratchpadPlugin (https://github.com/fuseraft/fuseraft-cli/blob/main/src/Infrastructure/Plugins/ScratchpadPlugin.cs) has no test file — there is no ScratchpadPluginTests.cs under tests/FuseraftCli.Tests/.

The plugin gives agents a small per-session JSON key/value store (WriteAsync, ReadAsync, ReadAllAsync, SearchAsync, DeleteAsync), scoped either to the current agent or shared via a global scope, backed by a JSON file at {BasePath}/{AgentName}.json (or {BasePath}/global.json). It's fully self-contained — no AI client or network mocking needed, just a temp directory.

Good first areas to cover:

  • Write then read round-trips a value, including tags
  • Read of a missing key returns the [NOT FOUND] message
  • ReadAllAsync on an empty scratchpad returns [EMPTY]
  • SearchAsync matches on key, value, and tag substrings (case-insensitively)
  • DeleteAsync removes an entry and returns [NOT FOUND] on a second delete
  • agent vs global scope write to different files and don't leak into each other
  • A corrupted/invalid JSON file on disk falls back to an empty scratchpad rather than throwing (see the catch in LoadAsync)

JsonPluginTests.cs and TodoPluginTests.cs (in the same tests/FuseraftCli.Tests/ directory) are good references for the file-backed-plugin test pattern used in this repo.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codegood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions