Skip to content

Commit

Permalink
test: RedisConfig 설정 변경으로 인한 테스트 수정 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwooo committed Jun 7, 2024
1 parent 2994c82 commit 3b0e7a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.event.RecordApplicationEvents;

@SpringBootTest
@RecordApplicationEvents
public class BestSellerServiceTest extends RedisTestContainer {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package com.jisungin.application.search;

import static org.assertj.core.api.Assertions.assertThat;

import com.jisungin.RedisTestContainer;
import com.jisungin.infra.s3.S3FileManager;
import java.util.List;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.test.context.event.RecordApplicationEvents;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@RecordApplicationEvents
public class SearchServiceTest extends RedisTestContainer {

@Autowired
private SearchService searchService;

@Autowired
private @Qualifier("redisTemplateSecond") RedisTemplate<String, String> redisTemplate;
private RedisTemplate<String, String> redisTemplate;

@MockBean
private S3FileManager s3FileManager;
Expand All @@ -46,7 +42,7 @@ void searchSaveRanking() {
//then
ZSetOperations<String, String> zset = redisTemplate.opsForZSet();
Double score = zset.score("ranking", keyword);
assertThat(score).isEqualTo(1.0); // 검색어의 점수가 1.0인지 확인
assertThat(score).isEqualTo(1.0);

}

Expand All @@ -61,7 +57,7 @@ void getRankKeywords() {

//then
List<String> rankKeywords = searchService.getRankKeywords();
Assertions.assertThat(rankKeywords).contains(keyword); // 랭킹에 추가된 검색어가 있는지 확인
Assertions.assertThat(rankKeywords).contains(keyword);
}

}

0 comments on commit 3b0e7a3

Please sign in to comment.