Skip to content

Commit

Permalink
[DEV-000] CI(test) 오류 수정 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Sep 7, 2024
1 parent 60ca922 commit 90e2050
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spring:
format_sql: true
dialect: org.hibernate.dialect.MySQL8Dialect
show-sql: true
defer-datasource-initialization: false
defer-datasource-initialization: true

sql:
init:
Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ INSERT INTO club(name,
introduction,
activity,
ideal,
form_url,
profile_image_url,
introduction_image_url)
form_url)
VALUES ('카우',
'학술',
'김세빈',
Expand All @@ -33,7 +31,5 @@ VALUES ('카우',
'동아리 소개입니다.',
'동아리 활동내용입니다.',
NULL,
NULL,
NULL,
NULL
);
2 changes: 1 addition & 1 deletion src/main/resources/db/migration/V4__Create_feed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CREATE TABLE feed (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
activity_content TEXT NOT NULL,
thumbnail_url VARCHAR(255) NOT NULL,
feed_type TINYINT NOT NULL,
feed_type VARCHAR(10) NOT NULL,
deleted_at DATETIME,
club_id BIGINT,
created_at DATETIME NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import ddingdong.ddingdongBE.domain.club.repository.ClubMemberRepository;
import ddingdong.ddingdongBE.domain.club.repository.ClubRepository;
import ddingdong.ddingdongBE.domain.club.service.dto.UpdateClubMemberCommand;
import ddingdong.ddingdongBE.domain.scorehistory.entity.Score;
import ddingdong.ddingdongBE.domain.user.entity.User;
import ddingdong.ddingdongBE.domain.user.repository.UserRepository;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
Expand Down Expand Up @@ -108,7 +110,10 @@ void updateClubList() throws IOException {
void update() {
//given
User savedUser = userRepository.save(fixtureMonkey.giveMeOne(User.class));
Club savedClub = clubRepository.save(fixtureMonkey.giveMeBuilder(Club.class).set("user", savedUser).sample());
Club savedClub = clubRepository.save(fixtureMonkey.giveMeBuilder(Club.class)
.set("user", savedUser)
.set("score", Score.from(BigDecimal.ZERO))
.sample());
ClubMember savedClubMember = clubMemberRepository.save(
fixtureMonkey.giveMeBuilder(ClubMember.class).set("club", savedClub).sample());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import ddingdong.ddingdongBE.domain.club.repository.ClubRepository;
import ddingdong.ddingdongBE.domain.feed.entity.Feed;
import ddingdong.ddingdongBE.domain.feed.entity.FeedType;
import ddingdong.ddingdongBE.domain.scorehistory.entity.Score;
import java.math.BigDecimal;
import java.util.List;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -15,49 +17,50 @@

class FeedRepositoryTest extends DataJpaTestSupport {

@Autowired
private ClubRepository clubRepository;
@Autowired
private ClubRepository clubRepository;

@Autowired
private FeedRepository feedRepository;
@Autowired
private FeedRepository feedRepository;

private final FixtureMonkey fixture = FixtureMonkeyFactory.getNotNullBuilderIntrospectorMonkey();
private final FixtureMonkey fixture = FixtureMonkeyFactory.getNotNullBuilderIntrospectorMonkey();

@DisplayName("동아리 ID로 해당 동아리의 모든 피드를 최신순으로 조회한다.")
@Test
void findAllByClubIdOrderById() {
// given
Club club = fixture.giveMeBuilder(Club.class)
.set("name", "카우")
.set("user", null)
.sample();
Club savedClub = clubRepository.save(club);
Feed feed1 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일1")
.set("feedType", FeedType.IMAGE)
.sample();
Feed feed2 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일2")
.set("feedType", FeedType.VIDEO)
.sample();
Feed feed3 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일3")
.set("feedType", FeedType.IMAGE)
.sample();
feedRepository.save(feed1);
feedRepository.save(feed2);
feedRepository.save(feed3);
// when
List<Feed> feeds = feedRepository.findAllByClubIdOrderById(savedClub.getId());
// then
Assertions.assertThat(feeds.get(0).getThumbnailUrl()).isEqualTo("썸네일3");
Assertions.assertThat(feeds.get(0).getId()).isEqualTo(3L);
Assertions.assertThat(feeds.get(1).getThumbnailUrl()).isEqualTo("썸네일2");
Assertions.assertThat(feeds.get(1).getId()).isEqualTo(2L);
Assertions.assertThat(feeds.get(2).getThumbnailUrl()).isEqualTo("썸네일1");
Assertions.assertThat(feeds.get(2).getId()).isEqualTo(1L);
}
}
@DisplayName("동아리 ID로 해당 동아리의 모든 피드를 최신순으로 조회한다.")
@Test
void findAllByClubIdOrderById() {
// given
Club club = fixture.giveMeBuilder(Club.class)
.set("name", "카우")
.set("user", null)
.set("score", Score.from(BigDecimal.ZERO))
.sample();
Club savedClub = clubRepository.save(club);
Feed feed1 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일1")
.set("feedType", FeedType.IMAGE)
.sample();
Feed feed2 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일2")
.set("feedType", FeedType.VIDEO)
.sample();
Feed feed3 = fixture.giveMeBuilder(Feed.class)
.set("club", savedClub)
.set("thumbnailUrl", "썸네일3")
.set("feedType", FeedType.IMAGE)
.sample();
feedRepository.save(feed1);
feedRepository.save(feed2);
feedRepository.save(feed3);
// when
List<Feed> feeds = feedRepository.findAllByClubIdOrderById(savedClub.getId());
// then
Assertions.assertThat(feeds.get(0).getThumbnailUrl()).isEqualTo("썸네일3");
Assertions.assertThat(feeds.get(0).getId()).isEqualTo(3L);
Assertions.assertThat(feeds.get(1).getThumbnailUrl()).isEqualTo("썸네일2");
Assertions.assertThat(feeds.get(1).getId()).isEqualTo(2L);
Assertions.assertThat(feeds.get(2).getThumbnailUrl()).isEqualTo("썸네일1");
Assertions.assertThat(feeds.get(2).getId()).isEqualTo(1L);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import ddingdong.ddingdongBE.domain.feed.entity.Feed;
import ddingdong.ddingdongBE.domain.feed.entity.FeedType;
import ddingdong.ddingdongBE.domain.feed.repository.FeedRepository;
import ddingdong.ddingdongBE.domain.scorehistory.entity.Score;
import java.math.BigDecimal;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -39,6 +41,7 @@ void getAllFeed() {
Club club = fixture.giveMeBuilder(Club.class)
.set("name", "카우")
.set("user", null)
.set("score", Score.from(BigDecimal.ZERO))
.sample();
Club savedClub = clubRepository.save(club);
Feed feed1 = fixture.giveMeBuilder(Feed.class)
Expand Down

0 comments on commit 90e2050

Please sign in to comment.