MCPcopy
hub / github.com/dunglas/mercure / TestBoltTransportHistory

Function TestBoltTransportHistory

bolt_test.go:37–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestBoltTransportHistory(t *testing.T) {
38 t.Parallel()
39
40 transport := createBoltTransport(t, 0, 0)
41
42 topics := []string{"https://example.com/foo"}
43 for i := 1; i <= 10; i++ {
44 require.NoError(t, transport.Dispatch(t.Context(), &Update{
45 Event: Event{ID: strconv.Itoa(i)},
46 Topics: topics,
47 }))
48 }
49
50 s := NewLocalSubscriber("8", transport.logger, &TopicSelectorStore{})
51 s.SetTopics(topics, nil)
52
53 require.NoError(t, transport.AddSubscriber(t.Context(), s))
54
55 var count int
56
57 for {
58 u := <-s.Receive()
59 // the reading loop must read the #9 and #10 messages
60 assert.Equal(t, strconv.Itoa(9+count), u.ID)
61
62 count++
63 if count == 2 {
64 return
65 }
66 }
67}
68
69func TestBoltTransportLogsBogusLastEventID(t *testing.T) {
70 t.Parallel()

Callers

nothing calls this directly

Calls 6

ReceiveMethod · 0.95
createBoltTransportFunction · 0.85
NewLocalSubscriberFunction · 0.85
SetTopicsMethod · 0.80
DispatchMethod · 0.65
AddSubscriberMethod · 0.65

Tested by

no test coverage detected