-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
register_test.go
65 lines (58 loc) · 975 Bytes
/
register_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package engine
import (
"context"
"testing"
)
type invalidTestStruct struct{}
func TestRegister(t *testing.T) {
ctx, cancel := _ctx(context.TODO())
defer cancel()
tests := []struct {
name string
key string
value interface{}
err bool
}{
{
"valid conductor registration",
ID(noopconductor{}),
&noopconductor{},
false,
},
{
"valid atom registration",
ID(noopatom{}),
&noopatom{},
false,
},
{
"invalid nil registration",
"",
nil,
true,
},
{
"invalid interface registration",
ID(invalidTestStruct{}),
invalidTestStruct{},
true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
reset(ctx, t)
defer reset(context.TODO(), t)
err := Register(test.value)
if err != nil && !test.err {
t.Fatal(err)
}
_, ok := registrant.Load(test.key)
if !ok && !test.err {
t.Fatalf(
"Test key [%s] failed to load",
test.key,
)
}
})
}
}