-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AbstractContainerBaseTest): redis 테스트 컨테이너 추가
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
main/src/test/java/org/sopt/makers/crew/main/external/AbstractContainerBaseTest.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,28 @@ | ||
package org.sopt.makers.crew.main.external; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.springframework.test.context.DynamicPropertySource; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
public abstract class AbstractContainerBaseTest { | ||
static final String REDIS_IMAGE = "redis:6-alpine"; | ||
static final GenericContainer REDIS_CONTAINER; | ||
|
||
static { | ||
REDIS_CONTAINER = new GenericContainer<>(REDIS_IMAGE) | ||
.withExposedPorts(6379) | ||
.withReuse(true) | ||
.waitingFor(Wait.forListeningPort()); | ||
REDIS_CONTAINER.start(); | ||
} | ||
|
||
@DynamicPropertySource | ||
public static void overrideProps(DynamicPropertyRegistry registry) { | ||
Supplier<Object> getHost = REDIS_CONTAINER::getHost; | ||
registry.add("spring.redis.host", getHost); | ||
registry.add("spring.redis.port", () -> "" + REDIS_CONTAINER.getMappedPort(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