-
Notifications
You must be signed in to change notification settings - Fork 11
/
udp_integration_test.go
59 lines (54 loc) · 1.11 KB
/
udp_integration_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
// +build integration
package riemanngo
import (
"testing"
"time"
)
func TestSendEventUdp(t *testing.T) {
c := NewUDPClient("127.0.0.1:5555", 5*time.Second)
err := c.Connect()
defer c.Close()
if err != nil {
t.Error("Error Udp client Connect")
}
result, err := SendEvent(c, &Event{
Service: "LOOOl",
Metric: 100,
Tags: []string{"nonblocking"},
})
if result != nil || err != nil {
t.Error("Error Udp client SendEvent")
}
}
func TestSendEventsUDP(t *testing.T) {
c := NewUDPClient("127.0.0.1:5555", 5*time.Second)
err := c.Connect()
defer c.Close()
if err != nil {
t.Error("Error Udp client Connect")
}
events := []Event{
{
Service: "hello",
Metric: 100,
Tags: []string{"hello"},
},
{
Service: "goodbye",
Metric: 200,
Tags: []string{"goodbye"},
},
}
result, err := SendEvents(c, &events)
if result != nil || err != nil {
t.Error("Error Udp client SendEvent")
}
}
func TestUDPConnec(t *testing.T) {
c := NewUDPClient("does.not.exists:8888", 5*time.Second)
// should produce an error
err := c.Connect()
if err == nil {
t.Error("Error, should fail")
}
}