-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
3 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
26 changes: 26 additions & 0 deletions
26
src/test/java/prography/cakeke/server/config/RedisTestContainers.java
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,26 @@ | ||
package prography.cakeke.server.config; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@DisplayName("Redis Test Containers") | ||
@Configuration | ||
public class RedisTestContainers { | ||
|
||
private static final String REDIS_DOCKER_IMAGE = "redis:5.0.3-alpine"; | ||
|
||
static { // (1) | ||
GenericContainer<?> REDIS_CONTAINER = | ||
new GenericContainer<>(DockerImageName.parse(REDIS_DOCKER_IMAGE)) | ||
.withExposedPorts(6379) | ||
.withReuse(true); | ||
|
||
REDIS_CONTAINER.start(); // (2) | ||
|
||
// (3) | ||
System.setProperty("spring.data.redis.host", REDIS_CONTAINER.getHost()); | ||
System.setProperty("spring.data.redis.port", REDIS_CONTAINER.getMappedPort(6379).toString()); | ||
} | ||
} |
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" | ||
|
||
services: | ||
redis: | ||
image: redis:7 | ||
command: redis-server --port 6379 | ||
ports: | ||
- "6380:6379" |