Feature/replace ioredis mock with testcontainers - #393
Open
d3v-active wants to merge 4 commits into
Open
Conversation
…e for read‑heavy queries
…igrations for SQLite dev
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.
Closes #252
Summary
This PR swaps the mock‑only Redis testing approach for a more realistic Docker‑based setup using Testcontainers. Real Redis (and PostgreSQL) containers are started only when Docker is available (e.g., in CI or developer environments with Docker). The existing mock‑based workflow remains unchanged for local development without Docker.
Why
ioredis-mockwithout any changes to their workflow.Changes Made
package.json(backend)ioredis-mockfor backward compatibility (local dev default).New Helper –
test/setup/testcontainers.tsstartTestContainers()to spin up a Redis container (@testcontainers/redis) and a PostgreSQL container (@testcontainers/postgresql).process.env.REDIS_URLandprocess.env.DATABASE_URL.stopTestContainers()for graceful teardown after tests.Jest Global Setup / Teardown
jest.global-setup.tsandjest.global-teardown.tsthat call the helper functions whenDOCKER_HOSTis set.)Test Modifications
app/backend/test/security.e2e-spec.ts:import RedisMock from 'ioredis-mock'.ioredis-mock.CI Integration (planned)
npm run test:realcan be added to run the test suite with Docker containers whenDOCKER_HOSTis present.How It Works
REDIS_URLis unset → the conditional code falls back toioredis-mock. No change to existing developer experience.startTestContainers(), launching Redis and PostgreSQL containers.Verification
npm run testlocally – all tests should still pass using the mock.npm run test:real(or the CI job) on a machine with Docker – containers start, tests execute, and the suite passes against a real Redis instance.Impact