-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient_test.go
73 lines (59 loc) · 1.25 KB
/
client_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
66
67
68
69
70
71
72
73
package client
import (
"testing"
"time"
"github.com/blushft/jitsuclient/event"
"github.com/blushft/jitsuclient/event/contexts"
"github.com/stretchr/testify/suite"
)
type ClientSuite struct {
suite.Suite
c *Client
}
func TestRunClientSuite(t *testing.T) {
suite.Run(t, new(ClientSuite))
}
func (s *ClientSuite) SetupSuite() {
tr, err := New(
TrackingID("tracker_test"),
ServerKey("s2s.f94blb9erxbasgzmdnnlwq.42ncq1nh3h4t1kz40amjx"),
SetAppInfo(&contexts.App{
Name: "tracker_test",
Version: "v0.1.0",
}),
Bulk(),
FlushInterval(time.Second*1),
Debug())
s.Require().NoError(err)
s.c = tr
}
func (s *ClientSuite) TearDownSuite() {
s.c.Close()
}
func (s *ClientSuite) TestTrackAction() {
a := &contexts.Action{
Category: "tests",
Action: "Test Action",
Label: "test_track",
Property: "test_val",
Value: 99,
}
s.c.Action(a)
time.Sleep(time.Second * 5)
}
func (s *ClientSuite) TestBulkEvents() {
for i := 0; i < 5000; i++ {
s.c.Queue(bulkEvent(i))
}
time.Sleep(time.Second * 15)
}
func bulkEvent(i int) *event.Event {
return event.New("bulk_event",
event.WithContext(&contexts.Action{
Category: "current_test",
Action: "Bulk Load",
Label: "test_bulk",
Property: "value",
Value: i,
}))
}