Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 레이블 수정 기능 #120

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
test : 레이블 수정 기능 테스트
  • Loading branch information
pie2457 committed Aug 9, 2023
commit d59e82a70c72c0fe39330059d59cb497a35c1529
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package kr.codesquad.issuetracker.application;

import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;

import java.util.Comparator;
import java.util.List;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,15 +27,24 @@ class LabelServiceTest {
@MockBean
private S3Service s3Service;

@BeforeEach
void setUp() {
databaseInitializer.initTables();
}

@DisplayName("label 목록 조회시 이름순으로 정렬이 된다.")
@Test
void findLabelsSortedNameAscending() {
assertThat(labelService.findAll())
.isSortedAccordingTo(Comparator.comparing(LabelResponse::getLabelName));
}

@DisplayName("label 수정에 성공한다.")
@Test
void modify() {
labelService.register("before", null, "white", "1234");
labelService.modify(1, "after", null, "black", "1111");
List<LabelResponse> result = labelService.findAll();

assertAll(
() -> assertThat(result.get(0).getLabelName()).isEqualTo("after"),
() -> assertThat(result.get(0).getFontColor()).isEqualTo("black"),
() -> assertThat(result.get(0).getBackgroundColor()).isEqualTo("1111"));

Copy link

Choose a reason for hiding this comment

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

48라인 공백 지워주세용

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ void register() {
assertThatCode(() -> labelService.register("feat", null, "#1234", "black"))
.doesNotThrowAnyException();
}

@DisplayName("레이블 수정에 성공한다.")
@Test
void modify() {
// given
willDoNothing().given(labelRepository).update(any(Label.class));

// when & then
assertThatCode(() -> labelService.modify(1, "after", null, "1111", "black"))
.doesNotThrowAnyException();
}
}