TestUnsubscribeMultipleChannels 测试多通道取消订阅
(t *testing.T)
| 325 | |
| 326 | // TestUnsubscribeMultipleChannels 测试多通道取消订阅 |
| 327 | func 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 | } |
nothing calls this directly
no test coverage detected