fcc-spring-boot-3
fcc-spring-boot-3 copied to clipboard
Corrected RunControllerTest::shouldDeleteRun test case
In the RunControllerTest.java, you have a failing test which was meant to mock deleting of run. You omit mocking the repository's findById method as seen below:
@Test
void shouldDeleteRun() throws Exception {
var run = new Run(null, "Test", LocalDateTime.now(), LocalDateTime.now().plusMinutes(1), 1, Location.OUTDOOR,
null);
when(repository.findById(ArgumentMatchers.anyInt())).thenReturn(Optional.of(run));
mvc.perform(delete("/api/runs/1"))
.andExpect(status().isNoContent());
}