From 49b0bc3aaaf3aec387c1fa5b6350a8d5f955e45d Mon Sep 17 00:00:00 2001 From: pierre818181 Date: Wed, 8 Jan 2025 11:40:37 -0600 Subject: [PATCH] send results once all jobs are done --- main.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 55cc10a..4391860 100644 --- a/main.go +++ b/main.go @@ -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)) @@ -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] @@ -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",