Skip to content

Commit

Permalink
test: 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kevstevie committed Aug 8, 2023
1 parent 08fbec9 commit 73b2a7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public TodoSteps(ObjectMapper objectMapper, SharedContext sharedContext) {

@Given("{string}가 찾은 회차에 {string}로 필수 투두를 추가한다.")
public void 투두_추가(String studyMemberGithubId, String content) throws JsonProcessingException {
TodoCreateRequest request = new TodoCreateRequest(
content
);
TodoCreateRequest request = new TodoCreateRequest(content);

given().log().all()
.contentType(MediaType.APPLICATION_JSON_VALUE)
Expand All @@ -46,9 +44,7 @@ public TodoSteps(ObjectMapper objectMapper, SharedContext sharedContext) {

@Given("{string}가 찾은 회차에 {string}로 선택 투두를 추가한다.")
public void 선택_투두_추가(String studyMemberGithubId, String content) throws JsonProcessingException {
TodoCreateRequest request = new TodoCreateRequest(
content
);
TodoCreateRequest request = new TodoCreateRequest(content);

ExtractableResponse<Response> response = given().log().all()
.contentType(MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.yigongil.backend.domain.round.Round;
import com.yigongil.backend.domain.round.RoundRepository;
import com.yigongil.backend.domain.roundofmember.RoundOfMember;
import com.yigongil.backend.exception.InvalidTodoLengthException;
import com.yigongil.backend.exception.NecessaryTodoAlreadyExistException;
import com.yigongil.backend.fixture.MemberFixture;
import com.yigongil.backend.request.TodoCreateRequest;
Expand Down Expand Up @@ -76,9 +77,21 @@ class 필수_투두 {
TodoCreateRequest request = new TodoCreateRequest("필수 투두");

//when
todoService.createNecessaryTodo(member, round.getId(), request);
//then
assertDoesNotThrow(() -> todoService.createNecessaryTodo(member, round.getId(), request));
}

@Test
void 투두가_20자_이상이면_예외가_발생한다() {
//given
willReturn(Optional.of(round)).given(roundRepository).findById(3L);

TodoCreateRequest request = new TodoCreateRequest("필수 투두를 20글자 이상으로 만들고 있습니다 아아");

//when
//then
assertThatThrownBy(() -> todoService.createNecessaryTodo(member, round.getId(), request))
.isInstanceOf(InvalidTodoLengthException.class);
}

@Test
Expand Down

0 comments on commit 73b2a7a

Please sign in to comment.