-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddr_impl_test.go
46 lines (33 loc) · 1.12 KB
/
addr_impl_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
40
41
42
43
44
45
46
package actorkit_test
import (
"strings"
"testing"
"github.com/gokit/actorkit"
"github.com/stretchr/testify/require"
)
func TestAddrAddressFormat(t *testing.T) {
system, err := actorkit.Ancestor("kitkat", "10.10.10.10:2020", actorkit.Prop{})
require.NoError(t, err)
require.NotNil(t, system)
require.Equal(t, "[email protected]:2020/"+system.ID()+"/access", system.Addr())
child, err := system.Spawn("runner", actorkit.Prop{Behaviour: &basic{}})
require.NoError(t, err)
require.NotNil(t, child)
require.Equal(t, "[email protected]:2020/"+system.ID()+"/"+child.ID()+"/runner", child.Addr())
actorkit.Destroy(system)
}
func TestDeadLetterAddr(t *testing.T) {
addr := actorkit.DeadLetters()
require.True(t, strings.HasPrefix(addr.Addr(), "kit@localhost"), "should have prefix %q", addr.Addr())
_, err := addr.Spawn("wap", actorkit.Prop{Behaviour: &basic{}})
require.Error(t, err)
_, err = addr.AddressOf("wap", true)
require.Error(t, err)
signal := make(chan struct{}, 1)
defer addr.Watch(func(_ interface{}) {
signal <- struct{}{}
}).Stop()
addr.Send("Welcome", addr)
require.Len(t, signal, 1)
<-signal
}