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 @@ -32,6 +32,9 @@ public class FeedCommandService {
public Long addFeed(FeedAddRequest request, List<MultipartFile> images, Long memberId) {
Long feedId = feedRepository.save(request.toFeed(memberId)).getId();

if (images == null || images.isEmpty()) {
return feedId;
}
messagePublisher.send(
new Message<>(
MessageType.IMAGES.name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.sillim.recordit.feed.dto.request.FeedAddRequest;
import com.sillim.recordit.feed.fixture.FeedFixture;
import com.sillim.recordit.feed.repository.FeedRepository;
import com.sillim.recordit.member.domain.Member;
import com.sillim.recordit.member.service.MemberQueryService;
import com.sillim.recordit.rabbitmq.service.MessagePublisher;
import java.io.IOException;
Expand All @@ -37,7 +36,6 @@ class FeedCommandServiceTest {
@Test
@DisplayName("피드를 추가할 수 있다.")
void addFeed() throws IOException {
Member member = mock(Member.class);
Feed feed = mock(Feed.class);
MockMultipartFile multipartFile =
new MockMultipartFile(
Expand All @@ -54,6 +52,19 @@ void addFeed() throws IOException {
assertThat(feedId).isEqualTo(1L);
}

@Test
@DisplayName("이미지 없이 피드를 추가할 수 있다.")
void addFeedWithoutImage() throws IOException {
Feed feed = mock(Feed.class);
given(feed.getId()).willReturn(1L);
given(feedRepository.save(any(Feed.class))).willReturn(feed);

FeedAddRequest feedAddRequest = new FeedAddRequest("title", "content");
Long feedId = feedCommandService.addFeed(feedAddRequest, null, 1L);

assertThat(feedId).isEqualTo(1L);
}

@Test
@DisplayName("피드를 지울 수 있다.")
void removeFeed() {
Expand Down
Loading