fix: close receipt delivery workflows
This commit is contained in:
@@ -4,8 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
cmpp "github.com/bigwhite/gocmpp"
|
||||
)
|
||||
|
||||
func TestSubmitResponseProtocolLoggerEmitsActualPacketDirection(t *testing.T) {
|
||||
@@ -50,3 +53,38 @@ func TestSubmitResponseProtocolLoggerEmitsActualPacketDirection(t *testing.T) {
|
||||
t.Fatal("timed out waiting for protocol event")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownstreamDeliverProtocolLoggerEmitsReceiptPacket(t *testing.T) {
|
||||
events := make(chan protocolLogEvent, 1)
|
||||
session := &downstreamSession{
|
||||
account: "607532", tenantID: "tenant-1", applicationID: "app-1",
|
||||
messageID: "MSG-LONG-1", phoneNumber: "18821203795", mu: &sync.Mutex{},
|
||||
protocolLog: func(event protocolLogEvent) { events <- event },
|
||||
}
|
||||
session.recordDownstreamProtocol(
|
||||
&cmpp.Cmpp2DeliverReqPkt{
|
||||
MsgId: 736078096490905600, SrcTerminalId: "18821203795", RegisterDelivery: 1,
|
||||
},
|
||||
"delivery-1",
|
||||
71,
|
||||
736078096490905600,
|
||||
"success",
|
||||
"",
|
||||
nil,
|
||||
)
|
||||
|
||||
select {
|
||||
case event := <-events:
|
||||
if event.Protocol != "cmpp" || event.Direction != "platform_to_client" || event.EventType != "deliver_receipt" {
|
||||
t.Fatalf("unexpected protocol event: %+v", event)
|
||||
}
|
||||
if event.TenantID != "tenant-1" || event.ApplicationID != "app-1" || event.Account != "607532" {
|
||||
t.Fatalf("unexpected application identifiers: %+v", event)
|
||||
}
|
||||
if event.MessageID != "MSG-LONG-1" || event.GatewayMessageID != "736078096490905600" || event.Phone != "18821203795" {
|
||||
t.Fatalf("unexpected message identifiers: %+v", event)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("timed out waiting for downstream deliver protocol event")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user