test: add vitest + pg-mem test infrastructure - #27
Conversation
Introduces the test harness (vitest, an in-memory Postgres via pg-mem, and `test`/`test:watch` scripts) with no real DB or secrets required, so future features can ship with unit tests. Included a UrlService smoke-test suite covering existing create/read/update/delete/search/sort/click-count behavior as the first consumer of the harness. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 56 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
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 |
Summary
vitest+pg-mem(in-memory Postgres),test/test:watchscripts, andvitest.config.ts(aliases@->./src, setsSKIP_ENV_VALIDATIONso importing modules doesn't require env config anddb.ts's startup init is skipped).src/lib/url-service.test.ts) covering existingUrlServicebehavior (create with random/custom code, duplicate rejection, lookup, update, delete, click count, pagination/search/sort) by mocking@/lib/db'sgetPoolwith a pg-mem-backed pool — no production code changed.This is pure test infrastructure, ported/adapted from the same pattern used in
vigab.cc(a fork of this project), and is a prerequisite for adding tests alongside upcoming features (tags, analytics, aliases).Test plan
pnpm test— 7 tests passpnpm check(biome) passespnpm buildsucceeds