forked from jwhited/bgpls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_test.go
40 lines (34 loc) · 1.15 KB
/
event_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
package bgpls
import (
"errors"
"net"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestEvent(t *testing.T) {
conf := &NeighborConfig{
ASN: 64512,
HoldTime: time.Second * 30,
Address: net.ParseIP("172.16.0.1").To4(),
}
cases := []struct {
event Event
t EventType
s string
}{
{newEventNeighborErr(conf, errors.New("test")), EventTypeNeighborErr, "neighbor error"},
{newEventNeighborHoldTimerExpired(conf), EventTypeNeighborHoldTimerExpired, "neighbor hold timer expired"},
{newEventNeighborNotificationReceived(conf, &NotificationMessage{}), EventTypeNeighborNotificationReceived, "received notification message from neighbor"},
{newEventNeighborStateTransition(conf, IdleState), EventTypeNeighborStateTransition, "neighbor state changed"},
{newEventNeighborUpdateReceived(conf, &UpdateMessage{}), EventTypeNeighborUpdateReceived, "received update message from neighbor"},
}
for _, c := range cases {
assert.Equal(t, c.event.Type(), c.t)
assert.Equal(t, c.event.Type().String(), c.s)
_ = c.event.Neighbor()
_ = c.event.Timestamp()
}
u := EventType(0)
assert.Equal(t, u.String(), "unknown event type")
}