github.com/zly-app/zapp@v1.3.3/component/msgbus/subscriber_test.go (about) 1 /* 2 ------------------------------------------------- 3 Author : zlyuancn 4 dateļ¼ 2021/3/19 5 Description : 6 ------------------------------------------------- 7 */ 8 9 package msgbus 10 11 import ( 12 "sync" 13 "testing" 14 15 "github.com/zly-app/zapp/core" 16 ) 17 18 func TestSubscriber(t *testing.T) { 19 var wg sync.WaitGroup 20 wg.Add(10) 21 22 s := newSubscriber(1, func(ctx core.IMsgbusContext) error { 23 ctx.Info(ctx.Msg()) 24 wg.Done() 25 return nil 26 }) 27 defer s.Close() 28 29 for i := 0; i < 10; i++ { 30 s.queue <- &channelMsg{ 31 topic: "topic", 32 msg: i, 33 } 34 } 35 36 wg.Wait() 37 }