// test the build function
func Test_Should_Build_Test_Sources(t *testing.T) {
	// given
	reportChan := make(chan message.Report, 1)
	defer close(reportChan)
	mes := message.ToWork{int64(1), message.PACKAGE, "toto-build-agent/testapp", "go1.6", "https://github.com/vil-coyote-acme/toto-example.git"}
	// when
	build.BuildPackage(mes, reportChan)
	msg := <-reportChan
	end := <-reportChan
	t.Logf("Test the go build command with succes. Output : %s\n\r", msg.Logs)
	assert.Contains(t, testtools.FromSliceToString(msg.Logs), "toto-build-agent/testapp")
	assert.Equal(t, msg.Status, message.WORKING)
	assert.Equal(t, end.Status, message.SUCCESS)
}
func Test_BuildPackage_should_failed_for_unknown_package(t *testing.T) {
	// given
	reportChan := make(chan message.Report, 1)
	defer close(reportChan)
	mes := message.ToWork{int64(1), message.PACKAGE, "plop/", "go1.6", "https://github.com/vil-coyote-acme/toto-example.git"}
	// when
	build.BuildPackage(mes, reportChan)
	msg := <-reportChan
	end := <-reportChan
	// then
	t.Logf("test the exec command failure. Output : %s, %d", msg.Logs, len(msg.Logs))
	assert.Contains(t, testtools.FromSliceToString(msg.Logs), "can't load package: package plop")
	assert.Equal(t, msg.Status, message.WORKING)
	assert.Equal(t, end.Status, message.FAILED)
}