Debian Codegraph @

metric/syncint64_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package metric // import "go.opentelemetry.io/otel/metric"
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10 )
11
12 func TestInt64Configuration(t *testing.T) {
13 const (
14 token int64 = 43
15 desc = "Instrument description."
16 uBytes = "By"
17 )
18
19 run := func(got int64Config) func(*testing.T) {
20 return func(t *testing.T) {
21 assert.Equal(t, desc, got.Description(), "description")
22 assert.Equal(t, uBytes, got.Unit(), "unit")
23 }
24 }
25
26 t.Run("Int64Counter", run(
27 NewInt64CounterConfig(WithDescription(desc), WithUnit(uBytes)),
28 ))
29
30 t.Run("Int64UpDownCounter", run(
31 NewInt64UpDownCounterConfig(WithDescription(desc), WithUnit(uBytes)),
32 ))
33
34 t.Run("Int64Histogram", run(
35 NewInt64HistogramConfig(WithDescription(desc), WithUnit(uBytes)),
36 ))
37
38 t.Run("Int64Gauge", run(
39 NewInt64GaugeConfig(WithDescription(desc), WithUnit(uBytes)),
40 ))
41 }
42
43 type int64Config interface {
44 Description() string
45 Unit() string
46 }
47
48 func TestInt64ExplicitBucketHistogramConfiguration(t *testing.T) {
49 bounds := []float64{0.1, 0.5, 1.0}
50 got := NewInt64HistogramConfig(WithExplicitBucketBoundaries(bounds...))
51 assert.Equal(t, bounds, got.ExplicitBucketBoundaries(), "boundaries")
52 }