-
Notifications
You must be signed in to change notification settings - Fork 23
/
sync_transport_test.go
86 lines (75 loc) · 1.95 KB
/
sync_transport_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
74
75
76
77
78
79
80
81
82
83
84
85
86
package rollbar
import (
"testing"
)
func TestSyncTransportSend(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
body := map[string]interface{}{
"hello": "world",
}
result := transport.Send(body)
if result != nil {
t.Error("Send returned an unexpected error:", result)
}
}
func TestSyncTransportSendTwice(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
body := map[string]interface{}{
"hello": "world",
}
transport.Send(body)
result := transport.Send(body)
if result != nil {
t.Error("Send returned an unexpected error:", result)
}
if transport.perMinCounter != 2 {
t.Error("shouldSend check failed")
}
}
func TestSyncTransportClose(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
result := transport.Close()
if result != nil {
t.Error("Close returned an unexpected error:", result)
}
}
func TestSyncTransportSetToken(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
token := "abc"
transport.SetToken(token)
if transport.Token != token {
t.Error("SetToken failed")
}
}
func TestSyncTransportSetEndpoint(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
endpoint := "https://fake.com"
transport.SetEndpoint(endpoint)
if transport.Endpoint != endpoint {
t.Error("SetEndpoint failed")
}
}
func TestSyncTransportNotSend(t *testing.T) {
transport := NewSyncTransport("", "")
transport.SetLogger(&SilentClientLogger{})
transport.SetItemsPerMinute(1)
if transport.ItemsPerMinute != 1 {
t.Error("SetItemsPerMinute failed")
}
body := map[string]interface{}{
"hello": "world",
}
transport.Send(body)
result := transport.Send(body)
if result != nil {
t.Error("Send returned an unexpected error:", result)
}
if transport.perMinCounter != 1 {
t.Error("shouldSend check failed")
}
}