update tests with new mq interface

This commit is contained in:
Carlos C
2016-10-04 18:45:59 +02:00
parent 0ecb6ca5cc
commit 6fd13e6754

View File

@@ -1,6 +1,7 @@
package runner
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -27,17 +28,19 @@ func getMockTask() models.Task {
}
func getTestServer(mockTasks []*models.Task) *httptest.Server {
ctx := context.TODO()
mq, err := mqs.New("memory://test")
if err != nil {
panic(err)
}
for _, mt := range mockTasks {
mq.Push(mt)
mq.Push(ctx, mt)
}
getHandler := func(c *gin.Context) {
task, err := mq.Reserve()
task, err := mq.Reserve(ctx)
if err != nil {
logrus.WithError(err)
c.JSON(http.StatusInternalServerError, err)
@@ -60,7 +63,7 @@ func getTestServer(mockTasks []*models.Task) *httptest.Server {
return
}
if err := mq.Delete(&task); err != nil {
if err := mq.Delete(ctx, &task); err != nil {
logrus.WithError(err)
c.JSON(http.StatusInternalServerError, err.Error())
return