-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathnoop_adapter_test.go
More file actions
42 lines (33 loc) · 937 Bytes
/
noop_adapter_test.go
File metadata and controls
42 lines (33 loc) · 937 Bytes
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 metrics
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNoopMetrics_ImplementsInterface(_ *testing.T) {
var _ Metrics = (*NoopMetrics)(nil)
}
func TestNoopMetrics_NoPanics(t *testing.T) {
m := NewNoopMetrics()
assert.NotPanics(t, func() {
m.Increment("key", map[string]string{"a": "b"})
m.Counter("key", map[string]string{"a": "b"}, 1)
m.Distribution("key", map[string]string{"a": "b"}, 1.5)
m.DistributionMs("key", map[string]string{"a": "b"}, time.Second)
})
}
func TestNoopMetrics_NilTags(t *testing.T) {
m := NewNoopMetrics()
assert.NotPanics(t, func() {
m.Increment("key", nil)
m.Counter("key", nil, 1)
m.Distribution("key", nil, 1.5)
m.DistributionMs("key", nil, time.Second)
})
}
func TestNoopMetrics_WithTags(t *testing.T) {
m := NewNoopMetrics()
tagged := m.WithTags(map[string]string{"env": "prod"})
assert.NotNil(t, tagged)
assert.Equal(t, m, tagged)
}