-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus_test.go
55 lines (49 loc) · 934 Bytes
/
prometheus_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
package exporter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSplitString(t *testing.T) {
var testCases = []struct {
input string
output string
}{
{
input: "GlobalTopicCount",
output: "Global.Topic.Count",
},
{
input: "CPUUtilization",
output: "CPUUtilization",
},
{
input: "StatusCheckFailed_Instance",
output: "Status.Check.Failed_Instance",
},
}
for _, tc := range testCases {
assert.Equal(t, tc.output, splitString(tc.input))
}
}
func TestSanitize(t *testing.T) {
var testCases = []struct {
input string
output string
}{
{
input: "Global.Topic.Count",
output: "Global_Topic_Count",
},
{
input: "Status.Check.Failed_Instance",
output: "Status_Check_Failed_Instance",
},
{
input: "IHaveA%Sign",
output: "IHaveA_percentSign",
},
}
for _, tc := range testCases {
assert.Equal(t, tc.output, sanitize(tc.input))
}
}