Convert MongoDB integration tests to use Testcontainers #10

Open
opened 2026-01-28 10:47:03 +00:00 by mprihoda · 0 comments
mprihoda commented 2026-01-28 10:47:03 +00:00 (Migrated from github.com)

Summary

Convert the MongoDB integration tests to use Testcontainers instead of requiring an external MongoDB instance.

Motivation

Currently, the MongoDB integration tests (mongo-it, files-mongo-it) require an external MongoDB instance and use TestAspect.ifEnvSet("MONGO_URI") to skip when unavailable. This means:

  • Tests are skipped in CI (no MongoDB available)
  • Developers need to manually run MongoDB locally
  • No automated verification of MongoDB-related code

The SQL testing modules already have proper Testcontainers support (MySQL, PostgreSQL) which should serve as a reference.

Current State

  • mongo/it/ - MongoJsonRepositoryIntegrationSpec - requires MONGO_URI env var
  • files/adapters/mongo/it/ - MongoJsonFileRepositoryIntegrationSpec - requires MONGO_URI env var
  • Both skip gracefully without the env var
  • No Docker/Testcontainers setup

Proposed Changes

  1. Add Testcontainers MongoDB dependency
  2. Create MongoTestingLayers similar to MySQLTestingLayers / PostgreSQLTestingLayers
  3. Update integration tests to use the Testcontainers-based layers
  4. Remove ifEnvSet("MONGO_URI") requirement (tests should run automatically)
  5. Update CI workflow to run MongoDB integration tests

Reference

See existing Testcontainers implementations:

  • sqldb-mysql/testing-support/src/main/scala/works/iterative/sqldb/mysql/testing/MySQLTestingLayers.scala
  • sqldb-postgresql/testing-support/src/main/scala/works/iterative/sqldb/postgresql/testing/PostgreSQLTestingLayers.scala

Created during SUPP-9 (CI and git hooks setup) - we're skipping MongoDB tests in CI until this is resolved.

## Summary Convert the MongoDB integration tests to use Testcontainers instead of requiring an external MongoDB instance. ## Motivation Currently, the MongoDB integration tests (`mongo-it`, `files-mongo-it`) require an external MongoDB instance and use `TestAspect.ifEnvSet("MONGO_URI")` to skip when unavailable. This means: - Tests are skipped in CI (no MongoDB available) - Developers need to manually run MongoDB locally - No automated verification of MongoDB-related code The SQL testing modules already have proper Testcontainers support (MySQL, PostgreSQL) which should serve as a reference. ## Current State - `mongo/it/` - `MongoJsonRepositoryIntegrationSpec` - requires `MONGO_URI` env var - `files/adapters/mongo/it/` - `MongoJsonFileRepositoryIntegrationSpec` - requires `MONGO_URI` env var - Both skip gracefully without the env var - No Docker/Testcontainers setup ## Proposed Changes 1. Add Testcontainers MongoDB dependency 2. Create `MongoTestingLayers` similar to `MySQLTestingLayers` / `PostgreSQLTestingLayers` 3. Update integration tests to use the Testcontainers-based layers 4. Remove `ifEnvSet("MONGO_URI")` requirement (tests should run automatically) 5. Update CI workflow to run MongoDB integration tests ## Reference See existing Testcontainers implementations: - `sqldb-mysql/testing-support/src/main/scala/works/iterative/sqldb/mysql/testing/MySQLTestingLayers.scala` - `sqldb-postgresql/testing-support/src/main/scala/works/iterative/sqldb/postgresql/testing/PostgreSQLTestingLayers.scala` ## Related Created during SUPP-9 (CI and git hooks setup) - we're skipping MongoDB tests in CI until this is resolved.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
iterative-works/support#10
No description provided.