New route to stop all running/pending tests for a given work

This commit is contained in:
nemunaire 2023-03-05 18:16:38 +01:00
parent 8b8f3947f8
commit bcf76a2c86
4 changed files with 90 additions and 0 deletions

View file

@ -153,6 +153,18 @@ func declareAPIAdminWorksRoutes(router *gin.RouterGroup) {
c.JSON(http.StatusOK, nil)
})
worksRoutes.DELETE("/tests", func(c *gin.Context) {
w := c.MustGet("work").(*Work)
err := w.stopTests()
if err != nil {
log.Println("Unable to stop tests:", err)
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during test stop."})
return
}
c.JSON(http.StatusOK, true)
})
// Grades related to works
worksRoutes.GET("/grades", func(c *gin.Context) {