51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package queue
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestSubmitCommandUnmarshalsQueuePriority(t *testing.T) {
|
|
payload := []byte(`{
|
|
"schemaVersion": "v1",
|
|
"messageType": "SubmitCommand",
|
|
"traceId": "trace-queue-0001",
|
|
"messageId": "msg-queue-0001",
|
|
"channelId": "channel-1",
|
|
"createdAt": "2026-07-07T10:00:00Z",
|
|
"tenantId": "tenant-1",
|
|
"applicationId": "app-1",
|
|
"submitId": "submit-1",
|
|
"phoneNumber": "13800138000",
|
|
"content": "hello",
|
|
"signature": "测试",
|
|
"templateId": "tpl-1",
|
|
"billingUnits": 1,
|
|
"queuePriority": "priority",
|
|
"route": {
|
|
"channelCode": "CMPP-A",
|
|
"cmppAccountCode": "account-a",
|
|
"priority": 1,
|
|
"rateLimitPerSecond": 100
|
|
},
|
|
"cmpp": {
|
|
"serviceId": "SMS",
|
|
"srcId": "10690000",
|
|
"registeredDelivery": 1,
|
|
"msgFmt": 8
|
|
},
|
|
"retry": {
|
|
"attempt": 0,
|
|
"maxAttempts": 3
|
|
}
|
|
}`)
|
|
|
|
var command SubmitCommand
|
|
if err := json.Unmarshal(payload, &command); err != nil {
|
|
t.Fatalf("unmarshal submit command: %v", err)
|
|
}
|
|
if command.QueuePriority != "priority" {
|
|
t.Fatalf("QueuePriority = %q, want priority", command.QueuePriority)
|
|
}
|
|
}
|