You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
952 B
40 lines
952 B
5 years ago
|
package metric
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestHistogramVec(t *testing.T) {
|
||
|
histogramVec := NewHistogramVec(&HistogramVecOpts{
|
||
|
Namespace: "test",
|
||
|
Subsystem: "test",
|
||
|
Name: "test",
|
||
|
Help: "this is test metrics.",
|
||
|
Labels: []string{"name", "addr"},
|
||
|
Buckets: _defaultBuckets,
|
||
|
})
|
||
|
histogramVec.Observe(int64(1), "name1", "127.0.0.1")
|
||
|
assert.Panics(t, func() {
|
||
|
NewHistogramVec(&HistogramVecOpts{
|
||
|
Namespace: "test",
|
||
|
Subsystem: "test",
|
||
|
Name: "test",
|
||
|
Help: "this is test metrics.",
|
||
|
Labels: []string{"name", "addr"},
|
||
|
Buckets: _defaultBuckets,
|
||
|
})
|
||
|
}, "Expected to panic.")
|
||
|
assert.NotPanics(t, func() {
|
||
|
NewHistogramVec(&HistogramVecOpts{
|
||
|
Namespace: "test",
|
||
|
Subsystem: "test",
|
||
|
Name: "test2",
|
||
|
Help: "this is test metrics.",
|
||
|
Labels: []string{"name", "addr"},
|
||
|
Buckets: _defaultBuckets,
|
||
|
})
|
||
|
}, "Expected normal. no panic.")
|
||
|
}
|