-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for Building DockerCompose Environments (#28)
* Add Support for Building DockerCompose Environments * Add To Docs * Remove unused Import * Add Docker Compose to Examples Folder * Add Docker Compose example Test NPM Script * Add Example and Fixup Port Mapping * Add Docker Compose Example to Travis * Update README with Docker Compose example
- Loading branch information
Showing
13 changed files
with
348 additions
and
11 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3.7" | ||
|
||
services: | ||
redis: | ||
image: redis:6 | ||
container_name: redis | ||
ports: | ||
- "6379" |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const redis = require('redis'); | ||
const { promisify } = require('util'); | ||
|
||
describe('docker compose example suite', () => { | ||
let redisClient; | ||
|
||
beforeAll(() => { | ||
const connectionUri = `redis://${global.__TESTCONTAINERS_REDIS_IP__}:${global.__TESTCONTAINERS_REDIS_PORT_6379__}`; | ||
redisClient = redis.createClient(connectionUri); | ||
}); | ||
|
||
afterAll(() => { | ||
redisClient.quit(); | ||
}); | ||
|
||
it("should set a container name", () => { | ||
expect(global.__TESTCONTAINERS_REDIS_NAME__).toBeDefined(); | ||
}); | ||
|
||
it('should write correctly', async () => { | ||
// Arrange | ||
const setAsync = promisify(redisClient.set).bind(redisClient); | ||
|
||
// Act | ||
const setResult = await setAsync('test', 73); | ||
|
||
// Assert | ||
expect(setResult).toEqual('OK'); | ||
}); | ||
|
||
it('should read the written value correctly', async () => { | ||
// Arrange | ||
const getAsync = promisify(redisClient.get).bind(redisClient); | ||
|
||
// Act | ||
const getResult = await getAsync('test'); | ||
|
||
// Assert | ||
expect(getResult).toEqual('73'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
dockerCompose: { | ||
composeFilePath: ".", | ||
composeFile: "docker-compose.yml", | ||
startupTimeout: 10000, | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
// preset: "@trendyol/jest-testcontainers", // should be like this in your project | ||
preset: "../../jest-preset.js" | ||
// make sure you are not setting *testEnvironment* to something (e.g. node). it should not be present. | ||
}; |
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.