Skip to content

Commit

Permalink
test: 회원 이름 중복 검사 Controller 테스트 코드 추가 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Sep 18, 2023
1 parent 2de76c1 commit f9b4734
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import com.project.mapdagu.domain.evaluation.dto.response.EvaluationsGetResponseDto;
import com.project.mapdagu.domain.evaluation.service.EvaluationService;
import com.project.mapdagu.domain.member.dto.request.MemberUpdateInfoRequestDto;
import com.project.mapdagu.domain.member.dto.request.MemberUserNameRequestDto;
import com.project.mapdagu.domain.member.dto.response.MemberReadInfoResponseDto;
import com.project.mapdagu.domain.member.dto.response.MemberReadMainResponseDto;
import com.project.mapdagu.domain.member.dto.response.MemberUserNameResponseDto;
import com.project.mapdagu.domain.member.service.MemberService;
import com.project.mapdagu.domain.test.dto.request.TestInfoRequestDto;
import com.project.mapdagu.utils.TestUserArgumentResolver;
Expand Down Expand Up @@ -106,4 +108,23 @@ void setUp() {
result.andExpect(status().isOk());
verify(memberService, times(1)).readMainInfo(anyString());
}

@Test
void 회원_이름_중복_검사() throws Exception {
//given
MemberUserNameRequestDto requestDto = new MemberUserNameRequestDto("test");
MemberUserNameResponseDto response = new MemberUserNameResponseDto(true);

//when
given(memberService.checkUserName(requestDto)).willReturn(response);
ResultActions result = mockMvc.perform(
post("/api/members/userName/isDuplicated")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(requestDto))
);

//then
result.andExpect(status().isOk());
verify(memberService, times(1)).checkUserName(requestDto);
}
}

0 comments on commit f9b4734

Please sign in to comment.