Skip to content

test: add unit tests for DB repositories, Sentry module, and Sentry router adapter#1008

Merged
aaight merged 1 commit intodevfrom
feature/add-unit-tests-db-sentry
Mar 23, 2026
Merged

test: add unit tests for DB repositories, Sentry module, and Sentry router adapter#1008
aaight merged 1 commit intodevfrom
feature/add-unit-tests-db-sentry

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 23, 2026

Summary

  • Add unit tests for 8 DB repository files: runsRepository (core CRUD + concurrency), runStatsRepository, llmCallsRepository, debugAnalysisRepository, runLogsRepository, webhookLogsRepository, joinHelpers
  • Add unit tests for 2 Sentry module files: sentry/client.ts (factory, API methods, URL construction, error handling) and sentry/integration.ts (config resolution, boolean delegation)
  • Add unit tests for router/adapters/sentry.ts (SentryRouterAdapter full interface: parseWebhook, isProcessableEvent, isSelfAuthored, resolveProject, dispatchWithCredentials, buildJob, postAck)
  • Update vitest.config.ts to include tests/unit/sentry/** in the unit-core project

Test details

11 new test files — 136+ new test cases:

File Tests
tests/unit/db/repositories/runsRepository-core.test.ts 17
tests/unit/db/repositories/runsRepository-concurrency.test.ts 22
tests/unit/db/repositories/runStatsRepository.test.ts 22
tests/unit/db/repositories/llmCallsRepository.test.ts 13
tests/unit/db/repositories/debugAnalysisRepository.test.ts 9
tests/unit/db/repositories/runLogsRepository.test.ts 7
tests/unit/db/repositories/webhookLogsRepository.test.ts 17
tests/unit/db/repositories/joinHelpers.test.ts 5
tests/unit/sentry/client.test.ts 19
tests/unit/sentry/integration.test.ts 13
tests/unit/router/adapters/sentry.test.ts 22

Testing approach

  • DB repositories: createMockDbWithGetDb() pattern from mockDb.ts + mockDbClientModule from sharedMocks.ts; schema mocked via vi.mock on src/db/schema/index.js
  • Sentry client: vi.stubEnv for token management, vi.stubGlobal('fetch') for HTTP mocking
  • Sentry integration: vi.mock on integrationsRepository with vi.mocked() for type-safe mock access
  • Router adapter: follows exact pattern from tests/unit/router/adapters/github.test.ts

Verification

  • All 344 test files pass (6552 tests)
  • TypeScript: zero errors
  • Biome lint: zero errors

Trello: https://trello.com/c/69c187eb70655f3bbeccf7ee

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

LGTM — Well-structured test suite covering 136+ cases across DB repositories, Sentry client/integration, and Sentry router adapter. Tests correctly verify actual implementation behavior (costUsd string conversion, null coalescing, URL encoding, processable resource filtering, concurrency edge cases). Follows established project patterns (mockDb helpers, sharedMocks, vi.mock hoisting). Vitest config change properly adds sentry tests to the unit-core project.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit 51ac4a7 into dev Mar 23, 2026
9 checks passed
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.

2 participants