Skip to content

Commit cd93168

Browse files
authored
test(cache): add oversized cache key boundary test (JhaSourav07#1935)
## Description Fixes JhaSourav07#1393 Added a boundary validation test for oversized cache keys in `lib/cache.test.ts`. This PR verifies that extremely large cache keys (`'a'.repeat(20000)`) are handled safely without crashes or unexpected behavior during cache operations. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A — this PR only adds a cache boundary validation test. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have starred the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 9910dc6 + 4eb4669 commit cd93168

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/cache.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,20 @@ describe('TTLCache', () => {
541541

542542
cache.destroy();
543543
});
544+
545+
it('handles oversized cache keys safely', () => {
546+
const cache = new TTLCache<string>();
547+
548+
const oversizedKey = 'a'.repeat(20000);
549+
550+
expect(() => {
551+
cache.set(oversizedKey, 'large-key-value', 60_000);
552+
}).not.toThrow();
553+
554+
expect(cache.get(oversizedKey)).toBe('large-key-value');
555+
556+
cache.destroy();
557+
});
544558
});
545559
});
546560

0 commit comments

Comments
 (0)