diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/repository/MemberFriendQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/repository/MemberFriendQueryRepositoryTest.java index 6e9105075..f66278ae5 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/repository/MemberFriendQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/friend/repository/MemberFriendQueryRepositoryTest.java @@ -13,12 +13,17 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import javax.sql.DataSource; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import org.springframework.data.domain.Slice; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; import org.springframework.test.context.TestConstructor; import org.springframework.test.context.TestConstructor.AutowireMode; import site.timecapsulearchive.core.common.RepositoryTest; @@ -37,6 +42,7 @@ @TestConstructor(autowireMode = AutowireMode.ALL) class MemberFriendQueryRepositoryTest extends RepositoryTest { + private static final String SQL_SCRIP_NAME = "member_tag_insert.sql"; private static final int MAX_COUNT = 10; private static final Long FRIEND_START_ID = 1L; private static final Long FRIEND_ID_TO_INVITE_OWNER = 11L; @@ -55,6 +61,14 @@ class MemberFriendQueryRepositoryTest extends RepositoryTest { new JPAQueryFactory(entityManager)); } + @BeforeAll + static void insertScript(@Autowired DataSource dataSource) { + Resource resource = new ClassPathResource(SQL_SCRIP_NAME); + ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator( + resource); + resourceDatabasePopulator.execute(dataSource); + } + @BeforeEach void setup(@Autowired EntityManager entityManager) { Member owner = MemberFixture.member(0); diff --git a/backend/core/src/test/resources/db/migration/V999__member_tag_insert.sql b/backend/core/src/test/resources/member_tag_insert.sql similarity index 80% rename from backend/core/src/test/resources/db/migration/V999__member_tag_insert.sql rename to backend/core/src/test/resources/member_tag_insert.sql index 5bd0618bb..79fc14af9 100644 --- a/backend/core/src/test/resources/db/migration/V999__member_tag_insert.sql +++ b/backend/core/src/test/resources/member_tag_insert.sql @@ -6,13 +6,13 @@ values (true, false, now(), 9999, now(), null, 'test_nickname_9999', 'KAKAO', ' (true, false, now(), 10003, now(), null, 'test_nickname_10003', 'KAKAO', 'test_email_10003@gmail.co', null, 'http://test_profile_url_10003.com', 'test_auth_id_10003', null, 'test_tag_10003', null); insert into member_friend(member_friend_id, owner_id, friend_id, created_at, updated_at) -values (1, 10000, 9999, now(), now()), - (2, 9999, 10000, now(), now()), - (3, 9999, 10001, now(), now()), - (4, 10001, 9999, now(), now()); +values (999, 10000, 9999, now(), now()), + (1000, 9999, 10000, now(), now()), + (1001, 9999, 10001, now(), now()), + (1002, 10001, 9999, now(), now()); insert into friend_invite(friend_invite_id, owner_id, friend_id, created_at, updated_at) -values (1, 10002, 9999, now(), now()), - (2, 9999, 10002, now(), now()), - (3, 9999, 10003, now(), now()), - (4, 10003, 9999, now(), now()); \ No newline at end of file +values (999, 10002, 9999, now(), now()), + (1000, 9999, 10002, now(), now()), + (1001, 9999, 10003, now(), now()), + (1002, 10003, 9999, now(), now()); \ No newline at end of file