Skip to content

test: enable dormant DB integration tests against testcontainers - #369

Open
mrofreP wants to merge 1 commit into
UndernetIRC:masterfrom
mrofreP:feat/enable-database-integration-tests
Open

test: enable dormant DB integration tests against testcontainers#369
mrofreP wants to merge 1 commit into
UndernetIRC:masterfrom
mrofreP:feat/enable-database-integration-tests

Conversation

@mrofreP

@mrofreP mrofreP commented Jul 18, 2026

Copy link
Copy Markdown

integration/database_integration_test.go was written before the
testcontainers-backed integration harness (main_test.go) landed and
was never re-enabled. Every top-level test and benchmark starts with
an unconditional t.Skip("... requires actual database setup"), while
main_test.go already provisions a real Postgres container and exposes
it via the package-level db (*models.Queries) and dbPool.

Wire the tests to the existing harness, drop the unconditional skips,
and delete three pure-placeholder tests whose bodies were just t.Log
("would be implemented here"): TestTransactionIntegrity,
TestConcurrentOperations, TestPerformanceQueries. They were dead
scaffolding, not tests.

Also:

  • Remove the unused local queries *models.Queries var and its stub
    setupTestDatabase helper; database/sql import goes with them.
  • testUserOperations now creates a per-run unique user with a valid
    username length and all required fields (language_id, question_id,
    verificationdata, signup_ts, last_updated_by), matching the pattern
    used in manager_change_test.go's setupTestChannelAndUser.
  • testChannelOperations / testChannelMembershipOperations /
    testComplexQueries keep their defensive t.Skip guards for the
    seeded-data cases, which is the correct behavior when running
    against a clean container.
  • BenchmarkChannelSearch and BenchmarkUserChannelMemberships lose
    their unconditional skips but keep the short-mode guard.

Net effect: TestDatabaseIntegration now runs 4 subtests
(User/Channel/Membership/Complex) against the real Postgres, adding
integration coverage to the sqlc-generated models package that
previously had 0% unit coverage.

integration/database_integration_test.go was written before the
testcontainers-backed integration harness (main_test.go) landed and
was never re-enabled. Every top-level test and benchmark starts with
an unconditional t.Skip("... requires actual database setup"), while
main_test.go already provisions a real Postgres container and exposes
it via the package-level db (*models.Queries) and dbPool.

Wire the tests to the existing harness, drop the unconditional skips,
and delete three pure-placeholder tests whose bodies were just t.Log
("would be implemented here"): TestTransactionIntegrity,
TestConcurrentOperations, TestPerformanceQueries. They were dead
scaffolding, not tests.

Also:
- Remove the unused local queries *models.Queries var and its stub
  setupTestDatabase helper; database/sql import goes with them.
- testUserOperations now creates a per-run unique user with a valid
  username length and all required fields (language_id, question_id,
  verificationdata, signup_ts, last_updated_by), matching the pattern
  used in manager_change_test.go's setupTestChannelAndUser.
- testChannelOperations / testChannelMembershipOperations /
  testComplexQueries keep their defensive t.Skip guards for the
  seeded-data cases, which is the correct behavior when running
  against a clean container.
- BenchmarkChannelSearch and BenchmarkUserChannelMemberships lose
  their unconditional skips but keep the short-mode guard.

Net effect: TestDatabaseIntegration now runs 4 subtests
(User/Channel/Membership/Complex) against the real Postgres, adding
integration coverage to the sqlc-generated models package that
previously had 0% unit coverage.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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