communicate/events/event_test.go

26 lines
426 B
Go
Raw Permalink Normal View History

2016-11-28 05:13:15 +00:00
package events
import (
"github.com/stretchr/testify/assert"
2017-05-29 10:53:29 +00:00
"git.loafle.net/commons/communicate"
2016-11-28 05:13:15 +00:00
"testing"
"time"
)
func TestCommunicatorGetResult(t *testing.T) {
const TEST_MESSAGE = "TEST"
e := &Event{Result: make(chan Result)}
communicate.Send(e)
go func() {
assert.Equal(t, TEST_MESSAGE, e.GetResult().Message)
}()
time.Sleep(time.Second)
go func() {
e.Result <- Result{Message: TEST_MESSAGE}
}()
}