-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat [ Test ]: migrate from redis-mock to redis testcontainer for tes…
…ts (#336) * set up redis testcontainert instead of redis-mock * cherry-pick tests refactoring * rm redundant file * refactor grouper tests * lint fix * lint fix
- Loading branch information
Showing
11 changed files
with
411 additions
and
108 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
const { GenericContainer } = require('testcontainers'); | ||
|
||
let redisTestContainer; | ||
|
||
/** | ||
* Mock redis library | ||
* Create test container with Redis, which could be used in tests | ||
*/ | ||
jest.mock('redis', () => jest.requireActual('redis-mock')); | ||
beforeAll(async () => { | ||
redisTestContainer = await new GenericContainer('redis') | ||
.withExposedPorts(6379) | ||
.start(); | ||
|
||
const port = redisTestContainer.getMappedPort(6379); | ||
const host = redisTestContainer.getContainerIpAddress(); | ||
|
||
/** | ||
* Set environment variable for redisHelper to connect to redis container | ||
*/ | ||
process.env.REDIS_URL = `redis://${host}:${port}`; | ||
} | ||
); | ||
|
||
afterAll(async () => { | ||
await redisTestContainer.stop(); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.