test: close coverage gaps and add DB integration test suite#12
Merged
Conversation
… 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/config,internal/models,internal/api/middleware,internal/api/router,internal/service, plus the remaining untested branches ofinternal/api/handlerandinternal/utils(database.go,logger.go).-tags integrationsuite (testcontainers-go + a real Postgres container) covering the DB-touching paths ininternal/utils(ConnectPool),internal/db(TableConstructor.Run()), andinternal/db/repository(TabulaRepositoryqueries).unit/integrationjobs (mirroring city2tabula's pattern), pluscodecov.ymlwithafter_n_builds: 2so the two uploads land together.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 unquotedWHERE code_buildingvariant = $1can't match the quoted mixed-case columnsTableConstructoractually creates, and even on a table shaped to match the filter,populateStructFromMaplooked 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 viaNewIgnisServiceWithDB, which nothing called), so this is dead-code removal, not a behavior change. The shared struct-mapping helpers it depended on moved tostruct_mapper.go, still used byTabulaRepository.GetVariant.Coverage:
config,models,api/middleware,api/router0% → 100%;utils~16% → 98.8%;api/handler62.1% → 97.4%;service0% → 88.2%;db0% → 91.8% (integration);db/repository0% → 89.4% (integration).Test plan
go build ./...go vet ./...andgo vet -tags integration ./...go test ./...— all packages passgo test -tags integration -timeout 5m ./internal/utils/ ./internal/db/ ./internal/db/repository/— all pass against a local Docker Postgres🤖 Generated with Claude Code