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

Function TestBoltTransportClosed

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

Source from the content-addressed store, hash-verified

256}
257
258func TestBoltTransportClosed(t *testing.T) {
259 t.Parallel()
260
261 transport := createBoltTransport(t, 0, 0)
262 assert.Implements(t, (*Transport)(nil), transport)
263
264 ctx := t.Context()
265
266 s := NewLocalSubscriber("", transport.logger, &TopicSelectorStore{})
267 s.SetTopics([]string{"https://example.com/foo"}, nil)
268 require.NoError(t, transport.AddSubscriber(ctx, s))
269
270 require.NoError(t, transport.Close(ctx))
271 require.Error(t, transport.AddSubscriber(ctx, s))
272
273 assert.Equal(t, transport.Dispatch(ctx, &Update{Topics: s.SubscribedTopics}), ErrClosedTransport)
274
275 _, ok := <-s.Receive()
276 assert.False(t, ok)
277}
278
279func TestBoltCleanDisconnectedSubscribers(t *testing.T) {
280 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected