Skip to content

Commit

Permalink
fix: user test
Browse files Browse the repository at this point in the history
  • Loading branch information
Village-GG-Water committed Nov 7, 2024
1 parent fa4a947 commit c624e2a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test/java/com/kert/UserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,18 @@ public void deleteUserByIdWithAdmin() throws Exception {
}

@Test
@DisplayName("delete user with not_admin")
public void deleteUserByIdWithNotAdmin() throws Exception {
mockMvc.perform(delete("/users/", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isForbidden());
@DisplayName("delete user with self")
public void deleteUserByIdWithSelf() throws Exception {
when(userService.getUserById(testUser.getStudentId())).thenReturn(testUser);

mockMvc.perform(delete("/users/{studentId}", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isNoContent());
}

@Test
@DisplayName("delete user with another")
public void deleteUserByIdWithAnother() throws Exception {
when(userService.getUserById(2L)).thenReturn(new User());

mockMvc.perform(delete("/users/2", testUser.getStudentId()).header("Authorization", "Bearer " + userJwtToken)).andExpect(status().isForbidden());
}
}

0 comments on commit c624e2a

Please sign in to comment.