Skip to content

Commit

Permalink
test: EventSchedule생성시 시작시간이 종료시간보다 늦을수 없다는 제약조건 테스트 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
haroya01 committed Nov 25, 2023
1 parent dd91e8e commit 4c327ca
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private byte[] createImageFile() throws IOException {
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8"))
.andDo(print())
.andExpect(status().isCreated());
.andExpect(status().isBadRequest());
}

@DisplayName("이벤트 전체 조회 - 성공")
Expand Down Expand Up @@ -703,4 +703,37 @@ private byte[] createImageFile() throws IOException {
.andExpect(status().isBadRequest());
}

@WithMockCustomUser(username = "user", role = "CURATOR")
@DisplayName("스케줄 종료시간이 시작시간보다 빠를시")
@Test
public void 스케줄_생성시_종료시간이_시작시간보다_빠른경우() throws Exception {
createOrLoadMember("user", RoleStatus.CURATOR, "ROLE_CURATOR");

ExhbitionCreateDTO dto = mockCreateExhibitionDTO(1);
EventScheduleCreateDTO eventScheduleCreateDTO = dto.getSchedule().get(0);
eventScheduleCreateDTO.setEndDateTime(LocalDateTime.now().minusHours(1));
eventScheduleCreateDTO.setStartDateTime(LocalDateTime.now());

MockMultipartFile dtoFile =
new MockMultipartFile("dto", "", "application/json", objectMapper.writeValueAsBytes(dto));

MockMultipartFile mediaFile =
new MockMultipartFile("mediaFiles", "image.jpg", "image/jpg", createImageFile());

MockMultipartFile thumbnailFile =
new MockMultipartFile("thumbnailFile", "image.jpg", "image/jpg", createImageFile());

mockMvc
.perform(
multipart("/api/exhibitions")
.file(dtoFile)
.file(mediaFile)
.file(thumbnailFile)
.contentType(MediaType.MULTIPART_FORM_DATA)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8"))
.andDo(print())
.andExpect(status().isBadRequest());
}

}

0 comments on commit 4c327ca

Please sign in to comment.