Skip to content

test: add vitest + pg-mem test infrastructure - #27

Open
viganogabriele wants to merge 1 commit into
mainfrom
test/vitest-pg-mem-infra
Open

test: add vitest + pg-mem test infrastructure#27
viganogabriele wants to merge 1 commit into
mainfrom
test/vitest-pg-mem-infra

Conversation

@viganogabriele

Copy link
Copy Markdown

Summary

  • Adds a test harness with no real DB/secrets required: vitest + pg-mem (in-memory Postgres), test/test:watch scripts, and vitest.config.ts (aliases @ -> ./src, sets SKIP_ENV_VALIDATION so importing modules doesn't require env config and db.ts's startup init is skipped).
  • Adds the first test suite (src/lib/url-service.test.ts) covering existing UrlService behavior (create with random/custom code, duplicate rejection, lookup, update, delete, click count, pagination/search/sort) by mocking @/lib/db's getPool with 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 pass
  • pnpm check (biome) passes
  • pnpm build succeeds

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>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@viganogabriele, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b237e6f-44e5-4396-9df8-2db908569234

📥 Commits

Reviewing files that changed from the base of the PR and between 8fb680c and 2e21278.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json
  • src/lib/url-service.test.ts
  • vitest.config.ts

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.

❤️ Share

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

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