Skip to content

Commit

Permalink
fix: truncate 를 통한 테스트 데이터 초기화
Browse files Browse the repository at this point in the history
  • Loading branch information
shin-mallang committed Jul 19, 2023
1 parent ae71fa3 commit 3c00dce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.jdbc.Sql;

@Sql("/truncate.sql")
@DisplayNameGeneration(ReplaceUnderscores.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public abstract class AcceptanceTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@SpringBootTest
@Sql("/truncate.sql")
@DisplayName("RestaurantQueryService 은(는)")
@DisplayNameGeneration(ReplaceUnderscores.class)
class RestaurantQueryServiceTest {
Expand Down
1 change: 0 additions & 1 deletion backend/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ logging:
org.hibernate.orm.jdbc.bind: TRACE
org.apache.coyote.http11: debug #Http 요청정보 로그 남기기


spring:
profiles:
active: test
Expand Down
6 changes: 6 additions & 0 deletions backend/src/test/resources/truncate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SET REFERENTIAL_INTEGRITY FALSE;
TRUNCATE TABLE celeb RESTART IDENTITY;
TRUNCATE TABLE restaurant RESTART IDENTITY;
TRUNCATE TABLE restaurant_image RESTART IDENTITY;
TRUNCATE TABLE video RESTART IDENTITY;
SET REFERENTIAL_INTEGRITY TRUE;

0 comments on commit 3c00dce

Please sign in to comment.