-
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.
enhancement: 테스트 환경 TestContainer 로 설정
- Loading branch information
1 parent
8366f2f
commit b86f6e4
Showing
9 changed files
with
45 additions
and
63 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
44 changes: 0 additions & 44 deletions
44
src/test/java/com/inq/wishhair/wesharewishhair/common/config/EmbeddedRedisConfig.java
This file was deleted.
Oops, something went wrong.
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
33 changes: 33 additions & 0 deletions
33
src/test/java/com/inq/wishhair/wesharewishhair/common/support/TestContainerSupport.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,33 @@ | ||
package com.inq.wishhair.wesharewishhair.common.support; | ||
|
||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.springframework.test.context.DynamicPropertySource; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
import org.testcontainers.containers.MySQLContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
public abstract class TestContainerSupport { | ||
|
||
private static final String REDIS_IMAGE = "redis:latest"; | ||
private static final int REDIS_PORT = 6379; | ||
private static final String MYSQL_IMAGE = "mysql:8"; | ||
|
||
private static final GenericContainer REDIS; | ||
private static final JdbcDatabaseContainer MYSQL; | ||
|
||
static { | ||
REDIS = new GenericContainer(DockerImageName.parse(REDIS_IMAGE)) | ||
.withExposedPorts(REDIS_PORT) | ||
.withReuse(true); | ||
MYSQL = new MySQLContainer(MYSQL_IMAGE); | ||
|
||
REDIS.start(); | ||
MYSQL.start(); | ||
} | ||
|
||
@DynamicPropertySource | ||
public static void overrideProps(DynamicPropertyRegistry registry){ | ||
registry.add("spring.data.redis.host", REDIS::getHost); | ||
registry.add("spring.data.redis.port", () -> String.valueOf(REDIS.getMappedPort(REDIS_PORT))); | ||
} | ||
} |
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