fcc-spring-boot-3 icon indicating copy to clipboard operation
fcc-spring-boot-3 copied to clipboard

Corrected RunControllerTest::shouldDeleteRun test case

Open solomonaboyeji opened this issue 1 year ago • 0 comments

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());
    }

solomonaboyeji avatar Apr 22 '24 16:04 solomonaboyeji