...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package metric
16
17 import (
18 "testing"
19
20 "github.com/stretchr/testify/assert"
21 )
22
23 func TestFloat64Configuration(t *testing.T) {
24 const (
25 token float64 = 43
26 desc = "Instrument description."
27 uBytes = "By"
28 )
29
30 run := func(got float64Config) func(*testing.T) {
31 return func(t *testing.T) {
32 assert.Equal(t, desc, got.Description(), "description")
33 assert.Equal(t, uBytes, got.Unit(), "unit")
34 }
35 }
36
37 t.Run("Float64Counter", run(
38 NewFloat64CounterConfig(WithDescription(desc), WithUnit(uBytes)),
39 ))
40
41 t.Run("Float64UpDownCounter", run(
42 NewFloat64UpDownCounterConfig(WithDescription(desc), WithUnit(uBytes)),
43 ))
44
45 t.Run("Float64Histogram", run(
46 NewFloat64HistogramConfig(WithDescription(desc), WithUnit(uBytes)),
47 ))
48 }
49
50 type float64Config interface {
51 Description() string
52 Unit() string
53 }
54
55 func TestFloat64ExplicitBucketHistogramConfiguration(t *testing.T) {
56 bounds := []float64{0.1, 0.5, 1.0}
57 got := NewFloat64HistogramConfig(WithExplicitBucketBoundaries(bounds...))
58 assert.Equal(t, bounds, got.ExplicitBucketBoundaries(), "boundaries")
59 }
60
View as plain text