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

Function TestBoltTopicSelectorHistory

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

Source from the content-addressed store, hash-verified

85}
86
87func TestBoltTopicSelectorHistory(t *testing.T) {
88 t.Parallel()
89
90 transport := createBoltTransport(t, 0, 0)
91 ctx := t.Context()
92
93 require.NoError(t, transport.Dispatch(ctx, &Update{Topics: []string{"https://example.com/subscribed"}, Event: Event{ID: "1"}}))
94 require.NoError(t, transport.Dispatch(ctx, &Update{Topics: []string{"https://example.com/not-subscribed"}, Event: Event{ID: "2"}}))
95 require.NoError(t, transport.Dispatch(ctx, &Update{Topics: []string{"https://example.com/subscribed-public-only"}, Private: true, Event: Event{ID: "3"}}))
96 require.NoError(t, transport.Dispatch(ctx, &Update{Topics: []string{"https://example.com/subscribed-public-only"}, Event: Event{ID: "4"}}))
97
98 s := NewLocalSubscriber(EarliestLastEventID, transport.logger, &TopicSelectorStore{})
99 s.SetTopics([]string{"https://example.com/subscribed", "https://example.com/subscribed-public-only"}, []string{"https://example.com/subscribed"})
100
101 require.NoError(t, transport.AddSubscriber(ctx, s))
102
103 assert.Equal(t, "1", (<-s.Receive()).ID)
104 assert.Equal(t, "4", (<-s.Receive()).ID)
105}
106
107func TestBoltTransportRetrieveAllHistory(t *testing.T) {
108 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