(t *testing.T)
| 226 | } |
| 227 | |
| 228 | func TestBoltTransportDispatch(t *testing.T) { |
| 229 | t.Parallel() |
| 230 | |
| 231 | transport := createBoltTransport(t, 0, 0) |
| 232 | assert.Implements(t, (*Transport)(nil), transport) |
| 233 | |
| 234 | ctx := t.Context() |
| 235 | |
| 236 | s := NewLocalSubscriber("", transport.logger, &TopicSelectorStore{}) |
| 237 | s.SetTopics([]string{"https://example.com/foo", "https://example.com/private"}, []string{"https://example.com/private"}) |
| 238 | |
| 239 | require.NoError(t, transport.AddSubscriber(ctx, s)) |
| 240 | |
| 241 | notSubscribed := &Update{Topics: []string{"not-subscribed"}} |
| 242 | require.NoError(t, transport.Dispatch(ctx, notSubscribed)) |
| 243 | |
| 244 | subscribedNotAuthorized := &Update{Topics: []string{"https://example.com/foo"}, Private: true} |
| 245 | require.NoError(t, transport.Dispatch(ctx, subscribedNotAuthorized)) |
| 246 | |
| 247 | public := &Update{Topics: s.SubscribedTopics} |
| 248 | require.NoError(t, transport.Dispatch(ctx, public)) |
| 249 | |
| 250 | assert.Equal(t, public, <-s.Receive()) |
| 251 | |
| 252 | private := &Update{Topics: s.AllowedPrivateTopics, Private: true} |
| 253 | require.NoError(t, transport.Dispatch(ctx, private)) |
| 254 | |
| 255 | assert.Equal(t, private, <-s.Receive()) |
| 256 | } |
| 257 | |
| 258 | func TestBoltTransportClosed(t *testing.T) { |
| 259 | t.Parallel() |
nothing calls this directly
no test coverage detected