Skip to content

Commit

Permalink
send results once all jobs are done
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre818181 committed Jan 8, 2025
1 parent 7d6d8bb commit 49b0bc3
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,6 @@ func (h *Handler) JobTake(c *gin.Context) {

currentTestPtr++

if currentTestPtr >= len(testConfig) {
sendResultsToGraphQL("PASSED", nil)
h.log.Error("No more tests", zap.Int("current_test", currentTestPtr))

c.JSON(500, gin.H{
"error": "No more tests",
})

return
}

nextTestPayload := testConfig[currentTestPtr]
testConfig[currentTestPtr].StartedAt = time.Now().UTC()
h.log.Info("Job take", zap.Any("next_test_payload", nextTestPayload))
Expand All @@ -235,7 +224,6 @@ func (h *Handler) JobTake(c *gin.Context) {
})
}

// CancelJob cancels a running job
func (h *Handler) JobDone(c *gin.Context) {
lastTest := testConfig[currentTestPtr]

Expand Down Expand Up @@ -286,6 +274,11 @@ func (h *Handler) JobDone(c *gin.Context) {
})
testConfig[currentTestPtr].Completed = true

if currentTestPtr == len(testConfig)-1 {
sendResultsToGraphQL("PASSED", nil)
h.log.Error("No more tests", zap.Int("current_test", currentTestPtr))
}

c.JSON(http.StatusOK, gin.H{
"status": "cancelled",
"message": "Job successfully cancelled",
Expand Down

0 comments on commit 49b0bc3

Please sign in to comment.