Skip to content

Commit c7da054

Browse files
committed
✅ test: RedissonTestContainerConfig 추가
1 parent 66eb5e2 commit c7da054

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.f1.backend.global.config;
2+
3+
import com.redis.testcontainers.RedisContainer;
4+
import org.redisson.Redisson;
5+
import org.redisson.api.RedissonClient;
6+
import org.redisson.config.Config;
7+
import org.springframework.context.annotation.Bean;
8+
import org.springframework.context.annotation.Configuration;
9+
import org.testcontainers.junit.jupiter.Container;
10+
import org.testcontainers.junit.jupiter.Testcontainers;
11+
12+
@Configuration
13+
@Testcontainers
14+
public class RedissonTestContainerConfig {
15+
16+
@Container
17+
public static RedisContainer redisContainer =
18+
new RedisContainer(
19+
RedisContainer.DEFAULT_IMAGE_NAME.withTag(RedisContainer.DEFAULT_TAG));
20+
21+
static {
22+
redisContainer.start();
23+
}
24+
25+
@Bean
26+
public RedissonClient redissonClient() {
27+
Config config = new Config();
28+
String address = String.format("redis://%s:%d",
29+
RedissonTestContainerConfig.redisContainer.getHost(),
30+
RedissonTestContainerConfig.redisContainer.getFirstMappedPort());
31+
32+
config.useSingleServer()
33+
.setAddress(address);
34+
35+
return Redisson.create(config);
36+
}
37+
}

0 commit comments

Comments
 (0)