MCPcopy
hub / github.com/mochi-mqtt/server / TestClientResendInflightMessages

Function TestClientResendInflightMessages

clients_test.go:397–415  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func TestClientResendInflightMessages(t *testing.T) {
398 pk1 := packets.TPacketData[packets.Puback].Get(packets.TPuback)
399 cl, r, w := newTestClient()
400
401 cl.State.Inflight.Set(*pk1.Packet)
402 require.Equal(t, 1, cl.State.Inflight.Len())
403
404 go func() {
405 err := cl.ResendInflightMessages(true)
406 require.NoError(t, err)
407 time.Sleep(time.Millisecond)
408 _ = w.Close()
409 }()
410
411 buf, err := io.ReadAll(r)
412 require.NoError(t, err)
413 require.Equal(t, 0, cl.State.Inflight.Len())
414 require.Equal(t, pk1.RawBytes, buf)
415}
416
417func TestClientResendInflightMessagesWriteFailure(t *testing.T) {
418 pk1 := packets.TPacketData[packets.Publish].Get(packets.TPublishQos1Dup)

Callers

nothing calls this directly

Calls 6

newTestClientFunction · 0.85
GetMethod · 0.65
CloseMethod · 0.65
SetMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected