|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+package mtglib_test
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "net"
|
|
|
5
|
+ "testing"
|
|
|
6
|
+ "time"
|
|
|
7
|
+
|
|
|
8
|
+ "github.com/9seconds/mtg/v2/mtglib"
|
|
|
9
|
+ "github.com/stretchr/testify/suite"
|
|
|
10
|
+)
|
|
|
11
|
+
|
|
|
12
|
+type EventsTestSuite struct {
|
|
|
13
|
+ suite.Suite
|
|
|
14
|
+}
|
|
|
15
|
+
|
|
|
16
|
+func (suite *EventsTestSuite) TestEventStart() {
|
|
|
17
|
+ evt := mtglib.EventStart{
|
|
|
18
|
+ CreatedAt: time.Now(),
|
|
|
19
|
+ ConnID: "CONNID",
|
|
|
20
|
+ RemoteIP: net.ParseIP("10.0.0.10"),
|
|
|
21
|
+ }
|
|
|
22
|
+
|
|
|
23
|
+ suite.Equal("CONNID", evt.StreamID())
|
|
|
24
|
+}
|
|
|
25
|
+
|
|
|
26
|
+func (suite *EventsTestSuite) TestEventFinish() {
|
|
|
27
|
+ evt := mtglib.EventFinish{
|
|
|
28
|
+ CreatedAt: time.Now(),
|
|
|
29
|
+ ConnID: "CONNID",
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
|
32
|
+ suite.Equal("CONNID", evt.StreamID())
|
|
|
33
|
+}
|
|
|
34
|
+
|
|
|
35
|
+func (suite *EventsTestSuite) TestEventConcurrencyLimited() {
|
|
|
36
|
+ suite.Empty(mtglib.EventConcurrencyLimited{}.StreamID())
|
|
|
37
|
+}
|
|
|
38
|
+
|
|
|
39
|
+func TestEvents(t *testing.T) {
|
|
|
40
|
+ t.Parallel()
|
|
|
41
|
+ suite.Run(t, &EventsTestSuite{})
|
|
|
42
|
+}
|