2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-20 09:16:12 +08:00

Update test to match the new API

This commit is contained in:
Ken Hibino
2021-03-17 09:07:43 -07:00
parent 848a03dc16
commit b3b50d26a2
12 changed files with 161 additions and 121 deletions

View File

@@ -6,6 +6,7 @@
package asynqtest
import (
"encoding/json"
"math"
"sort"
"testing"
@@ -111,6 +112,15 @@ func NewTaskMessageWithQueue(taskType string, payload []byte, qname string) *bas
}
}
// KV serializes the given key-value pairs into stream of bytes.
func KV(kv map[string]interface{}) []byte {
b, err := json.Marshal(kv)
if err != nil {
panic(err)
}
return b
}
// TaskMessageAfterRetry returns an updated copy of t after retry.
// It increments retry count and sets the error message.
func TaskMessageAfterRetry(t base.TaskMessage, errMsg string) *base.TaskMessage {