Skip to content

test: close coverage gaps and add DB integration test suite#12

Merged
jravani merged 1 commit into
mainfrom
test/coverage-and-integration-ci
Jul 24, 2026
Merged

test: close coverage gaps and add DB integration test suite#12
jravani merged 1 commit into
mainfrom
test/coverage-and-integration-ci

Conversation

@jravani

@jravani jravani commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Unit tests for previously 0%-covered packages: internal/config, internal/models, internal/api/middleware, internal/api/router, internal/service, plus the remaining untested branches of internal/api/handler and internal/utils (database.go, logger.go).
  • New -tags integration suite (testcontainers-go + a real Postgres container) covering the DB-touching paths in internal/utils (ConnectPool), internal/db (TableConstructor.Run()), and internal/db/repository (TabulaRepository queries).
  • CI split into unit / integration jobs (mirroring city2tabula's pattern), plus codecov.yml with after_n_builds: 2 so the two uploads land together.
  • Removes BuildingRepository/GetByBuildingCode/NewIgnisServiceWithDB (closes BuildingRepository.GetByBuildingCode cannot correctly populate a struct from any table shape #13): while writing repository integration tests, found this path was doubly broken — its unquoted WHERE code_buildingvariant = $1 can't match the quoted mixed-case columns TableConstructor actually creates, and even on a table shaped to match the filter, populateStructFromMap looked values up by the mixed-case JSON tag while Postgres returns unquoted columns lowercased, so fields never populated either way. It was unreachable from any handler (only wired via NewIgnisServiceWithDB, which nothing called), so this is dead-code removal, not a behavior change. The shared struct-mapping helpers it depended on moved to struct_mapper.go, still used by TabulaRepository.GetVariant.

Coverage: config, models, api/middleware, api/router 0% → 100%; utils ~16% → 98.8%; api/handler 62.1% → 97.4%; service 0% → 88.2%; db 0% → 91.8% (integration); db/repository 0% → 89.4% (integration).

Test plan

  • go build ./...
  • go vet ./... and go vet -tags integration ./...
  • go test ./... — all packages pass
  • go test -tags integration -timeout 5m ./internal/utils/ ./internal/db/ ./internal/db/repository/ — all pass against a local Docker Postgres

🤖 Generated with Claude Code

… utils

Adds unit tests for the packages that had zero or near-zero coverage
(config, models, api/middleware, api/router, service, and the
previously-untested branches of api/handler and internal/utils), plus
a testcontainers-backed integration suite (-tags integration) covering
the real-Postgres paths in internal/utils, internal/db and
internal/db/repository. CI is split into unit/integration jobs
mirroring city2tabula's pattern, with a matching codecov.yml.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jravani
jravani merged commit 62c4841 into main Jul 24, 2026
5 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.

BuildingRepository.GetByBuildingCode cannot correctly populate a struct from any table shape

2 participants