-
Notifications
You must be signed in to change notification settings - Fork 27
/
rename_test.go
68 lines (63 loc) · 1.05 KB
/
rename_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
package main
import "testing"
func Test_rename_metric(t *testing.T) {
cases := []struct {
name string
expect string
}{
{
name: "Foo",
expect: "foo",
}, {
name: "foo_bar",
expect: "foo_bar",
}, {
name: "foo.bar",
expect: "foo_bar",
}, {
name: "foo-bar",
expect: "foo_bar",
}, {
name: "foo$bar",
expect: "foo_bar",
}, {
name: "foo(bar)",
expect: "foo_bar",
},
}
for _, c := range cases {
name := renameMetric(c.name)
if name != c.expect {
t.Errorf("expected metric named %s, got %s", c.expect, name)
}
}
}
func Test_rename_rate(t *testing.T) {
cases := []struct {
name string
expect string
}{
{
name: "mean_rate",
expect: "mean",
}, {
name: "m1_rate",
expect: "1m",
}, {
name: "m5_rate",
expect: "5m",
}, {
name: "m15_rate",
expect: "15m",
}, {
name: "foo",
expect: "foo",
},
}
for _, c := range cases {
name := renameRate(c.name)
if name != c.expect {
t.Errorf("expected rate named %s, got %s", c.expect, name)
}
}
}