// start listening for toWork
// will start an embeded broker, a report producer and a toWork listener
func startListening() {
	// first start the broker
	logger.Info("Starting listening for jobs")
	embeddedBroker = broker.NewBroker()
	embeddedBroker.BrokerAddr = brokerAddr
	embeddedBroker.BrokerPort = brokerPort
	embeddedBroker.StartBroker()

	// start the report producer
	logger.Info("Starting the report producer")
	reportChan = make(chan message.Report, 20)
	producerConf := messaging.NewProducerConfig()
	producerConf.NsqAddr = brokerAddr + ":" + brokerPort
	producer := messaging.NewProducer(producerConf)
	producer.Start(reportChan)

	// start the work listener
	logger.Info("Starting the work listener")
	listenerConf := messaging.NewListenerConfig()
	listenerConf.LookupAddr = []string{nsqLookUpHost + ":" + nsqLookUpPort}
	listener = messaging.NewListener(listenerConf)
	// must create the topic BEFORE listing on it
	sayHello(listenerConf.Topic)
	toWorkChan = listener.Start()

	// and then start executing incoming job
	logger.Info("Starting execution incoming Jobs")
	build.ExecuteJob(toWorkChan, reportChan)

	logger.Info("Agent setup done")
}
func Test_ExecuteJob_Should_Reply_To_Hello(t *testing.T) {
	// given
	toWorkChan := make(chan message.ToWork)
	reportChan := make(chan message.Report, 1)
	defer close(reportChan)
	defer close(toWorkChan)
	// when
	build.ExecuteJob(toWorkChan, reportChan)
	toWorkChan <- message.ToWork{int64(1), message.HELLO, "", "go1.6", "https://github.com/vil-coyote-acme/toto-example.git"}
	msg := <-reportChan
	t.Logf("Test the go build command with succes. Output : %s\n\r", msg.Logs)
	assert.Contains(t, testtools.FromSliceToString(msg.Logs), "Hello")
	assert.Equal(t, msg.Status, message.SUCCESS)
}