Skip to content

Commit

Permalink
fix : flyway -> datasource script run
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed May 29, 2024
1 parent 1824c1a commit 9870909
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]', 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());
values (999, 10002, 9999, now(), now()),
(1000, 9999, 10002, now(), now()),
(1001, 9999, 10003, now(), now()),
(1002, 10003, 9999, now(), now());

0 comments on commit 9870909

Please sign in to comment.