-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecorders_test.go
50 lines (44 loc) · 1007 Bytes
/
recorders_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
package main
import (
"testing"
)
var (
recorder = StatsDRecorder{}
)
var validStatTests = []struct {
Input string
Expected bool
}{
{"/", true},
{"foo/bar", true},
{"/foo/bar", true},
{"/foo/bar/", true},
{"/foo/bar///", false},
{"/about.html", true},
{"/company/about.png.php", true},
}
func TestStatsdValidStat(t *testing.T) {
for _, tt := range validStatTests {
if ret := recorder.validStat(tt.Input); ret != tt.Expected {
t.Errorf("input was %v and expected %v, but got %v", tt.Input, tt.Expected, ret)
}
}
}
var uriTests = []struct {
Input string
Expected string
}{
{"/", "index."},
{"foo/bar", "foo.bar."},
{"/foo/bar", "foo.bar."},
{"/foo/bar/", "foo.bar.index."},
{"/about.html", "about."},
{"/company/about.png.php", "company.about."},
}
func TestCleanURI(t *testing.T) {
for _, tt := range uriTests {
if ret := recorder.cleanURI(tt.Input); ret != tt.Expected {
t.Errorf("input was %v and expected %v, but got %v", tt.Input, tt.Expected, ret)
}
}
}