Skip to content

Commit 2fc49ae

Browse files
committed
Test: Redis 연결 테스트
1 parent ebbd303 commit 2fc49ae

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.back;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.data.redis.core.StringRedisTemplate;
7+
import org.springframework.test.context.ActiveProfiles;
8+
9+
import static org.assertj.core.api.Assertions.assertThat;
10+
11+
@SpringBootTest
12+
@ActiveProfiles("test")
13+
class RedisConnectionTest {
14+
15+
@Autowired
16+
private StringRedisTemplate redisTemplate;
17+
18+
@Test
19+
void redisShouldStoreAndGetValue() {
20+
// given
21+
String key = "test:key";
22+
String value = "hello";
23+
24+
// when
25+
redisTemplate.opsForValue().set(key, value);
26+
String result = redisTemplate.opsForValue().get(key);
27+
28+
// then
29+
assertThat(result).isEqualTo(value);
30+
}
31+
}

0 commit comments

Comments
 (0)