func Test_Embedded_Broker_On_Publish(t *testing.T) { // given b := broker.NewBroker() b.Start() defer b.Stop() // and config := nsq.NewConfig() p, errP := nsq.NewProducer("127.0.0.1:4150", config) // when errPub := p.Publish("myTopic", make([]byte, 256)) //then assert.Nil(t, errP) assert.Nil(t, errPub) assert.NotNil(t, p) }
func Test_SetupListener(t *testing.T) { // given b := broker.NewBroker() b.Start() defer b.Stop() //and config := nsq.NewConfig() p, _ := nsq.NewProducer("127.0.0.1:4150", config) report := message.Report{int64(1), message.PENDING, []string{"test"}} body, _ := json.Marshal(report) p.Publish("test", body) //when channel, consumer := testtools.SetupListener("test", b.LookUpHttpAddrr+":"+b.LookUpHttpPort) // then assert.NotNil(t, consumer) assert.NotNil(t, channel) assert.Equal(t, report, <-channel) }