func Test_Reception_Of_One_ToWork_Message(t *testing.T) {
	// given the listener
	c := messaging.NewListenerConfig()
	c.LookupAddr = []string{"127.0.0.1:24161"}
	l := messaging.NewListener(c)
	defer l.Stop()
	// broker initialization
	b := broker.NewBroker()
	b.BrokerPort = "24150"
	b.BrokerHttpPort = "24151"
	b.LookUpTcpPort = "24160"
	b.LookUpHttpPort = "24161"
	b.Start()
	defer b.Stop()
	// test message creation
	mess := message.ToWork{int64(1), message.TEST, "myPkg", "go1.6", "https://github.com/vil-coyote-acme/toto-example.git"}
	body, _ := json.Marshal(mess)
	// message sending
	config := nsq.NewConfig()
	p, _ := nsq.NewProducer("127.0.0.1:24150", config)
	p.Publish(c.Topic, body)
	// when
	incomingChan := l.Start()
	// then
	assert.Equal(t, message.ToWork{int64(1), message.TEST, "myPkg", "go1.6", "https://github.com/vil-coyote-acme/toto-example.git"}, <-incomingChan)
}
// 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_NewConfig(t *testing.T) {
	// when
	conf := messaging.NewListenerConfig()
	// then
	assert.Equal(t, "buld-agent", conf.Channel)
	assert.Equal(t, "jobs", conf.Topic)
	assert.Equal(t, 10, conf.BuffSize)
}