-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_test.go
39 lines (32 loc) · 905 Bytes
/
message_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package message_channel
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func TestNewChannel(t *testing.T) {
options := NewChannelOptions[string]().WithChannelConsumerFunc(func(index int, message string) {
t.Log(fmt.Sprintf("index = %d, message = %s", index, message))
})
channel := NewChannel[string](options)
assert.NotNil(t, channel)
}
func TestChannel_MakeChildChannel(t *testing.T) {
}
func TestChannel_Single(t *testing.T) {
options := NewChannelOptions[string]().WithChannelConsumerFunc(func(index int, message string) {
t.Log(fmt.Sprintf("index = %d, message = %s", index, message))
})
channel := NewChannel[string](options)
go func() {
for i := 0; i < 10; i++ {
channel.Send(fmt.Sprintf("message %d", i))
time.Sleep(time.Second)
}
channel.SenderWaitAndClose()
}()
channel.ReceiverWait()
}
func TestChannel_Very_Complex(t *testing.T) {
}