Added safety tests for AdapterCacheRedis error and edge-case paths#27479
Conversation
7ad6196 to
2f759fc
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds new integration and unit tests for the Redis cache adapter covering error and retry scenarios. Integration tests assert that a rejected fetch function is not cached, that a subsequent 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ghost/core/test/unit/server/adapters/lib/redis/adapter-cache-redis.test.js`:
- Around line 202-239: The test must assert the background refresh actually ran:
after creating the RedisCache and stubbing fetchData to resolve then reject,
call cache.get(KEY, fetchData) twice and then assert that fetchData was invoked
twice (e.g., fetchData.calledTwice) to prove the refresh attempt occurred; also
stub the cache/logger error method (or processLogger.error depending on how
RedisCache logs) before the second call and assert that the error logger was
called with the refresh error to ensure the refresh failure path was exercised —
reference the RedisCache constructor, cache.get, and the fetchData stub when
adding these assertions.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b112399f-161f-4fde-a160-18fec512f24a
📒 Files selected for processing (2)
ghost/core/test/integration/adapters/redis/adapter-cache-redis.test.jsghost/core/test/unit/server/adapters/lib/redis/adapter-cache-redis.test.js
ref #19627 - We're preparing to merge changes to the Redis cache adapter(concurrent read deduplication from PR #19627). These tests lock in the current error-handling behavior, so any behavioral regression is caught immediately. - The current adapter silently swallows errors in several paths and the exact behavior isn't documented by existing tests. PR #19627 changes the `get` method structure to share in-flight promises, which makes error paths more sensitive — one failure now affects all callers waiting on the same key. We need to know exactly how errors behave today before changing anything.
The existing test verified the return value was correct but never proved the refresh actually ran or that the error was handled. It would still pass if the background refresh code path were removed entirely. Added assertions that fetchData was called twice (proving the refresh attempt) and that logging.error received the structured error object from the .catch handler (proving the failure path was exercised). A short setTimeout drains the microtask queue so the fire-and-forget .catch callback has settled before we assert.
7424702 to
4ad177f
Compare
|



ref #19627 HKG-1709
getmethod structure to share in-flight promises, which makes error paths more sensitive — one failure now affects all callers waiting on the same key. We need to know exactly how errors behave today before changing anything.