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

Function TestBoltTransportRetrieveAllHistory

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

Source from the content-addressed store, hash-verified

105}
106
107func TestBoltTransportRetrieveAllHistory(t *testing.T) {
108 t.Parallel()
109
110 transport := createBoltTransport(t, 0, 0)
111 ctx := t.Context()
112
113 topics := []string{"https://example.com/foo"}
114 for i := 1; i <= 10; i++ {
115 require.NoError(t, transport.Dispatch(ctx, &Update{
116 Event: Event{ID: strconv.Itoa(i)},
117 Topics: topics,
118 }))
119 }
120
121 s := NewLocalSubscriber(EarliestLastEventID, transport.logger, &TopicSelectorStore{})
122 s.SetTopics(topics, nil)
123 require.NoError(t, transport.AddSubscriber(ctx, s))
124
125 var count int
126
127 for {
128 u := <-s.Receive()
129 // the reading loop must read all messages
130 count++
131 assert.Equal(t, strconv.Itoa(count), u.ID)
132
133 if count == 10 {
134 break
135 }
136 }
137
138 assert.Equal(t, 10, count)
139}
140
141func TestBoltTransportHistoryAndLive(t *testing.T) {
142 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