Skip to content

[035-focus-store-unit-tests]: Unit tests for MarkdownFocusStore#41

Merged
archae0pteryx merged 2 commits into
mainfrom
chore/focus-store-unit-tests
May 5, 2026
Merged

[035-focus-store-unit-tests]: Unit tests for MarkdownFocusStore#41
archae0pteryx merged 2 commits into
mainfrom
chore/focus-store-unit-tests

Conversation

@archae0pteryx
Copy link
Copy Markdown
Contributor

@archae0pteryx archae0pteryx commented May 4, 2026

Closes issues/035-focus-store-unit-tests.md

Completion promise: MarkdownFocusStore has direct unit tests covering the create/list/delete/task mutation cycle and timer sidecar edge cases; the storage seam is independently trusted without Commands.

Summary

  • 8 new unit tests in focus_store.rs covering the acceptance table
  • All tests use TempDir; corrupted_timer_json_degrades_gracefully captures the slug returned by create_focus instead of hardcoding it
  • list() degrades to timer: None on corrupted timer.json instead of failing the whole load
  • Drop stale ralph/ Taskfile include left over from dabed05

Test plan

  • cargo test -p adhd-ranch-storage green in isolation
  • task check green

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Focus operations now gracefully handle corrupted timer configuration files, allowing the system to continue processing instead of failing entirely when timer data is malformed.
  • Tests

    • Extended test coverage for focus management workflows, including creation, listing, and deletion with proper timer file handling and graceful degradation of corrupted configuration data.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2fcc2ef9-f39d-45c9-842b-5789fc2d0514

📥 Commits

Reviewing files that changed from the base of the PR and between 785c1e1 and 0bce410.

📒 Files selected for processing (1)
  • crates/storage/src/focus_store.rs

📝 Walkthrough

Walkthrough

MarkdownFocusStore::list() now gracefully handles malformed timer.json sidecars by setting focus.timer to None rather than failing the entire listing operation. Comprehensive unit tests verify the create/list/delete cycle, timer sidecar presence, and degraded behavior with corrupted JSON.

Changes

Timer Resilience & Test Coverage

Layer / File(s) Summary
Error Handling
crates/storage/src/focus_store.rs (lines 111–119)
list() method switches from failing on JSON parse errors to graceful degradation: serde_json::from_str(&raw).ok() returns None when parsing fails, allowing listing to continue with focus.timer = None.
Tests & Verification
crates/storage/src/focus_store.rs (lines 409–572)
New Issue 035 unit tests verify the full create/list/delete lifecycle, confirm timer sidecar presence and absence, validate that corrupted timer.json results in timer: None without failing list(), and confirm task persistence across append_task and delete_task mutations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A JSON mishap? Not today!
We parse with grace, none shall fray,
When timers break mid-read,
We carry on instead,
And tests ensure we're here to stay! 📋✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding unit tests for MarkdownFocusStore. It is concise, specific, and directly reflects the primary contribution of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/focus-store-unit-tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/storage/src/focus_store.rs`:
- Around line 534-551: The test corrupted_timer_json_degrades_gracefully
hardcodes the slug "broken-timer" when building timer_path; change it to capture
the slug returned by MarkdownFocusStore::create_focus and use that slug to
construct timer_path so the test no longer depends on slugify behavior. Instruct
the test to call store.create_focus(...) and save its returned slug (or result)
instead of ignoring it, then use that slug when joining "<slug>/timer.json" to
write the corrupted JSON; update any variable names (e.g., timer_path)
accordingly so the test remains focused on sidecar corruption only.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6c3ab3d1-da75-4645-bf10-ec34edbf4297

📥 Commits

Reviewing files that changed from the base of the PR and between 287eab2 and e20db99.

📒 Files selected for processing (1)
  • crates/storage/src/focus_store.rs

Comment thread crates/storage/src/focus_store.rs
@archae0pteryx archae0pteryx force-pushed the chore/focus-store-unit-tests branch from e20db99 to 785c1e1 Compare May 5, 2026 02:29
archae0pteryx added a commit that referenced this pull request May 5, 2026
- CHANGELOG: Unreleased entries for PRs #39 (033), #40 (034), #41
  (035), #42 (cleanup), and the Taskfile ralph-include fix
- CONTEXT: add TaskText and DomainError to the ubiquitous language
- issues/README: mark 033/034/035 as in-flight (PR open)
Closes issues/035-focus-store-unit-tests.md

Completion promise: MarkdownFocusStore has direct unit tests covering
the create/list/delete/task mutation cycle and timer sidecar edge
cases; the storage seam is independently trusted without Commands.

- 8 new tests in focus_store.rs covering acceptance table
- corrupted_timer_json now uses captured slug, not slugify assumption
- list() degrades to timer: None on corrupted timer.json instead of
  failing the whole load
- Drop stale ralph/ Taskfile include left over from dabed05
@archae0pteryx archae0pteryx force-pushed the chore/focus-store-unit-tests branch from 785c1e1 to 0bce410 Compare May 5, 2026 04:56
archae0pteryx added a commit that referenced this pull request May 5, 2026
- CHANGELOG: Unreleased entries for PRs #39 (033), #40 (034), #41
  (035), #42 (cleanup), and the Taskfile ralph-include fix
- CONTEXT: add TaskText and DomainError to the ubiquitous language
- issues/README: mark 033/034/035 as in-flight (PR open)
@archae0pteryx archae0pteryx merged commit ee9fd0f into main May 5, 2026
1 of 2 checks passed
archae0pteryx added a commit that referenced this pull request May 5, 2026
- CHANGELOG: Unreleased entries for PRs #39 (033), #40 (034), #41
  (035), #42 (cleanup), and the Taskfile ralph-include fix
- CONTEXT: add TaskText and DomainError to the ubiquitous language
- issues/README: mark 033/034/035 as in-flight (PR open)
archae0pteryx added a commit that referenced this pull request May 5, 2026
…tus (#43)

- CHANGELOG: Unreleased entries for PRs #39 (033), #40 (034), #41
  (035), #42 (cleanup), and the Taskfile ralph-include fix
- CONTEXT: add TaskText and DomainError to the ubiquitous language
- issues/README: mark 033/034/035 as in-flight (PR open)
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