26 lines
422 B
Go
26 lines
422 B
Go
|
package events
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"loafle.com/commons/communicate"
|
||
|
"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}
|
||
|
}()
|
||
|
}
|