func Test_Main_should_Start_An_Nsq_Service(t *testing.T) {
	//given
	initVar()
	b := startLookUp()
	defer b.Stop()
	// when
	startListening()
	defer graceFullShutDown()
	sendMsg()
	// then
	receip, consumer := testtools.SetupListener("report", b.LookUpHttpAddrr+":"+b.LookUpHttpPort)
	defer close(receip)
	defer consumer.Stop()
	assert.NotNil(t, consumer)
	assert.NotNil(t, receip)
	// first get the hello from the agent, then the message with the build log and finally the last report with
	// the build status (should be SUCCESS here)
	hello := <-receip
	buildTrace := <-receip
	finalReport := <-receip

	assert.Contains(t, testtools.FromSliceToString(hello.Logs), "Hello")
	assert.Equal(t, hello.Status, message.SUCCESS)
	assert.Contains(t, testtools.FromSliceToString(buildTrace.Logs), "toto-build-agent/testapp")
	assert.Equal(t, buildTrace.Status, message.WORKING)
	assert.Equal(t, finalReport.Status, message.SUCCESS)
}
func Test_Producer_Start(t *testing.T) {
	// given
	c := NewProducerConfig()
	c.NsqAddr = "127.0.0.1:14150"
	p := NewProducer(c)
	// and broker initialization
	b := broker.NewBroker()
	b.BrokerPort = "14150"
	b.BrokerHttpPort = "14151"
	b.LookUpTcpPort = "14160"
	b.LookUpHttpPort = "14161"
	b.Start()
	defer b.Stop()
	// when
	ch := make(chan message.Report, 20)
	p.Start(ch)
	mes := message.Report{int64(1), message.PENDING, []string{"test"}}
	ch <- mes
	// and test listener
	receip, consumer := testtools.SetupListener(c.Topic, b.LookUpHttpAddrr+":"+b.LookUpHttpPort)
	// then
	assert.Equal(t, mes, <-receip)
	consumer.Stop()
}