From f112700a0cd0ab18b46e652dacd78bda0140a6b6 Mon Sep 17 00:00:00 2001 From: ohhamma Date: Mon, 22 Jul 2024 18:27:12 +0900 Subject: [PATCH] KL-100/test: revise test code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔드포인트를 controller와 동일하게 수정 - 입력한 dummy data에 맞게 예상 속성값 수정 --- .../user/Integration/UserIntegrationTest.java | 15 ++++----------- .../user/controller/UserControllerTest.java | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/test/java/taco/klkl/domain/user/Integration/UserIntegrationTest.java b/src/test/java/taco/klkl/domain/user/Integration/UserIntegrationTest.java index ceebac19..f521433d 100644 --- a/src/test/java/taco/klkl/domain/user/Integration/UserIntegrationTest.java +++ b/src/test/java/taco/klkl/domain/user/Integration/UserIntegrationTest.java @@ -14,7 +14,6 @@ import taco.klkl.domain.user.dao.UserRepository; import taco.klkl.domain.user.domain.User; import taco.klkl.domain.user.service.UserService; -import taco.klkl.global.common.enums.Gender; @SpringBootTest @AutoConfigureMockMvc @@ -29,19 +28,13 @@ public class UserIntegrationTest { @Autowired UserRepository userRepository; - User user; - @Test public void testUserMe() throws Exception { - // given - User user = new User(null, "testUser", Gender.MALE, 20, "테스트 유저입니다."); - - // when - userRepository.save(user); - user = userService.me(); + // given, when + User user = userService.me(); // then - mockMvc.perform(get("/api/v1/users/me")) + mockMvc.perform(get("/v1/users/me")) .andExpect(status().isOk()) .andExpect(jsonPath("$.isSuccess", is(true))) .andExpect(jsonPath("$.code", is("C000"))) @@ -50,7 +43,7 @@ public void testUserMe() throws Exception { .andExpect(jsonPath("$.data.gender", is(user.getGender().toString()))) .andExpect(jsonPath("$.data.age", is(user.getAge()))) .andExpect(jsonPath("$.data.description", is(user.getDescription()))) - .andExpect(jsonPath("$.data.profile", is("image/default.jpg"))) + .andExpect(jsonPath("$.data.profile", is("image/test.jpg"))) .andExpect(jsonPath("$.data.createdAt", notNullValue())) .andExpect(jsonPath("$.timestamp", notNullValue())); } diff --git a/src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java b/src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java index 15763aee..b62a1ca2 100644 --- a/src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java +++ b/src/test/java/taco/klkl/domain/user/controller/UserControllerTest.java @@ -39,7 +39,7 @@ public void getMe() throws Exception { Mockito.when(userService.me()).thenReturn(user); // when & then - mockMvc.perform(get("/api/v1/users/me") + mockMvc.perform(get("/v1/users/me") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.isSuccess", is(true)))