mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-22 22:06:12 +08:00
Use protobuf to encode task message
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
package asynqtest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math"
|
||||
"sort"
|
||||
"testing"
|
||||
@@ -130,7 +129,7 @@ func TaskMessageWithError(t base.TaskMessage, errMsg string) *base.TaskMessage {
|
||||
// Calling test will fail if marshaling errors out.
|
||||
func MustMarshal(tb testing.TB, msg *base.TaskMessage) string {
|
||||
tb.Helper()
|
||||
data, err := json.Marshal(msg)
|
||||
data, err := base.EncodeMessage(msg)
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
@@ -141,12 +140,11 @@ func MustMarshal(tb testing.TB, msg *base.TaskMessage) string {
|
||||
// Calling test will fail if unmarshaling errors out.
|
||||
func MustUnmarshal(tb testing.TB, data string) *base.TaskMessage {
|
||||
tb.Helper()
|
||||
var msg base.TaskMessage
|
||||
err := json.Unmarshal([]byte(data), &msg)
|
||||
msg, err := base.DecodeMessage(data)
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
}
|
||||
return &msg
|
||||
return msg
|
||||
}
|
||||
|
||||
// MustMarshalSlice marshals a slice of task messages and return a slice of
|
||||
|
Reference in New Issue
Block a user