70 lines
1.7 KiB
Go
70 lines
1.7 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",
|
|
"extensionDigits": 4,
|
|
"registeredDelivery": 1,
|
|
"msgFmt": 8
|
|
},
|
|
"upstream": {
|
|
"gatewayHost": "127.0.0.1",
|
|
"gatewayPort": 17890,
|
|
"account": "account-a",
|
|
"passwordCipher": "secret",
|
|
"cmppVersion": "3.0",
|
|
"desiredConnections": 2,
|
|
"windowSize": 16
|
|
},
|
|
"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)
|
|
}
|
|
if command.Upstream.GatewayHost != "127.0.0.1" || command.Upstream.Account != "account-a" {
|
|
t.Fatalf("unexpected upstream config: %+v", command.Upstream)
|
|
}
|
|
if command.Upstream.DesiredConnections != 2 || command.Upstream.WindowSize != 16 {
|
|
t.Fatalf("unexpected upstream window config: %+v", command.Upstream)
|
|
}
|
|
if command.CMPP.ExtensionDigits != 4 {
|
|
t.Fatalf("unexpected extension digits: %d", command.CMPP.ExtensionDigits)
|
|
}
|
|
}
|