forked from marpaia/graphite-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphite_test.go
47 lines (40 loc) · 1.02 KB
/
graphite_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
package graphite
import (
"fmt"
"net"
"testing"
)
// Change these to be your own graphite server if you so please
var graphiteHost = "carbon.hostedgraphite.com"
var graphitePort = 2003
var graphiteAddress = fmt.Sprintf("%s:%d", graphiteHost, graphitePort)
func TestNewGraphite(t *testing.T) {
gh, err := NewGraphite(graphiteHost, graphitePort)
if err != nil {
t.Error(err)
}
if _, ok := gh.conn.(*net.TCPConn); !ok {
t.Error("GraphiteHost.conn is not a TCP connection")
}
}
func TestNewGraphiteFromAddress(t *testing.T) {
gh, err := NewGraphiteFromAddress(graphiteAddress)
if err != nil {
t.Error(err)
}
if _, ok := gh.conn.(*net.TCPConn); !ok {
t.Error("GraphiteHost.conn is not a TCP connection")
}
}
// Uncomment the following method to test sending an actual metric to graphite
//
//func TestSendMetric(t *testing.T) {
// gh, err := NewGraphite(graphiteHost, graphitePort)
// if err != nil {
// t.Error(err)
// }
// err = gh.SimpleSend("stats.test.metric11", "1")
// if err != nil {
// t.Error(err)
// }
//}