-
Notifications
You must be signed in to change notification settings - Fork 0
/
cws_test.go
42 lines (33 loc) · 1.01 KB
/
cws_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
package tune
import (
"testing"
"github.com/franela/goblin"
. "github.com/onsi/gomega"
)
func TestCSWStatter(t *testing.T) {
g := goblin.Goblin(t)
RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })
g.Describe("Buckets", func() {
g.It("should split a bucket string if multiple segments exist", func() {
b := "get.endpoint-name.subaction"
dn, dv, m := metricNames(b)
Expect(dn).To(Equal("get"))
Expect(dv).To(Equal("endpoint-name"))
Expect(m).To(Equal("subaction"))
})
g.It("should return the same string if multiple segments do not exist", func() {
b := "endpoint-name"
dn, dv, m := metricNames(b)
Expect(dn).To(Equal("endpoint-name"))
Expect(dv).To(Equal("endpoint-name"))
Expect(m).To(Equal("endpoint-name"))
})
g.It("should handle a really long set of segments", func() {
b := "get.some.endpoint.subaction.count"
dn, dv, m := metricNames(b)
Expect(dn).To(Equal("get"))
Expect(dv).To(Equal("some.endpoint.subaction"))
Expect(m).To(Equal("count"))
})
})
}