forked from beenanner/rsyslog_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputs_test.go
38 lines (29 loc) · 926 Bytes
/
inputs_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
package main
import "testing"
var (
inputLog = []byte(`{"name":"test_input", "origin":"imuxsock", "submitted":1000}`)
)
func TestgetInput(t *testing.T) {
logType := getStatType(inputLog)
if logType != rsyslogInput {
t.Errorf("detected pstat type should be %d but is %d", rsyslogInput, logType)
}
pstat := newInputFromJSON([]byte(inputLog))
if want, got := "test_input", pstat.Name; want != got {
t.Errorf("want '%s', got '%s'", want, got)
}
if want, got := int64(1000), pstat.Submitted; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
}
func TestInputtoPoints(t *testing.T) {
pstat := newInputFromJSON([]byte(inputLog))
points := pstat.toPoints()
point := points[0]
if want, got := "test_input_submitted", point.Name; want != got {
t.Errorf("want '%s', got '%s'", want, got)
}
if want, got := int64(1000), point.Value; want != got {
t.Errorf("want '%d', got '%d'", want, got)
}
}