Skip to content

Commit

Permalink
test: use messagepipe
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF committed Feb 1, 2024
1 parent c493707 commit 514dd2f
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions ably/realtime_channel_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,36 +295,26 @@ func TestRealtimeChannel_ShouldSetProvidedReadLimit(t *testing.T) {
}

func TestRealtimeChannel_SetsNoLimitIfServerNoLimits(t *testing.T) {
// Mock out the dial
dial := DialFunc(func(p string, url *url.URL, timeout time.Duration) (ably.Conn, error) {
return connMock{
SendFunc: func(m *ably.ProtocolMessage) error {
return nil
},
ReceiveFunc: func(deadline time.Time) (*ably.ProtocolMessage, error) {
connDetails := ably.ConnectionDetails{
ClientID: "id1",
ConnectionKey: "foo",
MaxFrameSize: 12,
MaxInboundRate: 14,
MaxMessageSize: 0,
ConnectionStateTTL: ably.DurationFromMsecs(time.Minute * 2),
MaxIdleInterval: ably.DurationFromMsecs(time.Second),
}

return &ably.ProtocolMessage{
Action: ably.ActionConnected,
ConnectionID: "connection-id-1",
ConnectionDetails: &connDetails,
}, nil
},
CloseFunc: func() error {
return nil
},
}, nil
})
in := make(chan *ably.ProtocolMessage, 1)
out := make(chan *ably.ProtocolMessage, 16)

_, c := ablytest.NewRealtime(ably.WithDial(MessagePipe(in, out)))

connDetails := ably.ConnectionDetails{
ClientID: "id1",
ConnectionKey: "foo",
MaxFrameSize: 12,
MaxInboundRate: 14,
MaxMessageSize: 0,
ConnectionStateTTL: ably.DurationFromMsecs(time.Minute * 2),
MaxIdleInterval: ably.DurationFromMsecs(time.Second),
}

_, c := ablytest.NewRealtime(ably.WithDial(dial))
in <- &ably.ProtocolMessage{
Action: ably.ActionConnected,
ConnectionID: "connection-id-1",
ConnectionDetails: &connDetails,
}

// Wait for a little bit for things to settle
time.Sleep(1 * time.Second)
Expand Down

0 comments on commit 514dd2f

Please sign in to comment.