Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public record PostListResponse(
ZonedDateTime createdAt,
ZonedDateTime updatedAt,
String postCategory,
String url
String postThumbnailUrl
Comment on lines 15 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 pr과 관련은 없지만 불필요한 Long타입 나중에 한 번 싹 고치는 pr 제가 올리겠습니다!

) {

public static PostListResponse from(Post post) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,44 @@ void setUp() {
() -> assertThat(redisService.isKeyExists(validateKey)).isTrue()
);
}

@Test
void 게시글_목록_조회시_첫번째_이미지를_썸네일로_반환한다() {
// given
String firstImageUrl = "first-thumbnail-url";
String secondImageUrl = "second-thumbnail-url";
postImageFixture.게시글_이미지(firstImageUrl, post1);
postImageFixture.게시글_이미지(secondImageUrl, post1);

// when
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategory(
BoardCode.FREE.name(),
PostCategory.전체.name()
);

// then
PostListResponse postResponse = actualResponses.stream()
.filter(p -> p.id().equals(post1.getId()))
.findFirst()
.orElseThrow();

assertThat(postResponse.postThumbnailUrl()).isEqualTo(firstImageUrl);
}

@Test
void 게시글에_이미지가_없다면_썸네일로_null을_반환한다() {
// when
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategory(
BoardCode.FREE.name(),
PostCategory.전체.name()
);

// then
PostListResponse postResponse = actualResponses.stream()
.filter(p -> p.id().equals(post3.getId()))
.findFirst()
.orElseThrow();

assertThat(postResponse.postThumbnailUrl()).isNull();
}
}
Loading