MCPcopy Create free account
hub / github.com/astercloud/aster / TestUnsubscribeMultipleChannels

Function TestUnsubscribeMultipleChannels

pkg/events/bus_test.go:327–347  ·  view source on GitHub ↗

TestUnsubscribeMultipleChannels 测试多通道取消订阅

(t *testing.T)

Source from the content-addressed store, hash-verified

325
326// TestUnsubscribeMultipleChannels 测试多通道取消订阅
327func TestUnsubscribeMultipleChannels(t *testing.T) {
328 eb := NewEventBus()
329 defer eb.Close()
330
331 // 订阅多个通道
332 ch := eb.Subscribe([]types.AgentChannel{
333 types.ChannelProgress,
334 types.ChannelControl,
335 types.ChannelMonitor,
336 }, nil)
337
338 eb.Unsubscribe(ch)
339
340 eb.mu.RLock()
341 totalSubs := len(eb.progressSubs) + len(eb.controlSubs) + len(eb.monitorSubs)
342 eb.mu.RUnlock()
343
344 if totalSubs != 0 {
345 t.Errorf("expected 0 total subscribers, got %d", totalSubs)
346 }
347}

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
SubscribeMethod · 0.95
UnsubscribeMethod · 0.95
NewEventBusFunction · 0.85

Tested by

no test coverage detected