Debian Codegraph @

cmd/mdatagen/internal/metric_test.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package internal
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10
11 "go.opentelemetry.io/collector/pdata/pmetric"
12 )
13
14 func TestMetricData(t *testing.T) {
15 for _, arg := range []struct {
16 metricData MetricData
17 wantType string
18 wantHasAggregated bool
19 wantHasMonotonic bool
20 wantInstrument string
21 wantAsync bool
22 }{
23 {&Gauge{}, "Gauge", false, false, "Gauge", false},
24 {&Gauge{Async: true}, "Gauge", false, false, "ObservableGauge", true},
25 {&Gauge{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt}, Async: true}, "Gauge", false, false, "Int64ObservableGauge", true},
26 {&Gauge{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble}, Async: true}, "Gauge", false, false, "Float64ObservableGauge", true},
27 {&Sum{}, "Sum", true, true, "UpDownCounter", false},
28 {&Sum{Mono: Mono{true}}, "Sum", true, true, "Counter", false},
29 {&Sum{Async: true}, "Sum", true, true, "ObservableUpDownCounter", true},
30 {&Sum{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt}, Async: true}, "Sum", true, true, "Int64ObservableUpDownCounter", true},
31 {&Sum{MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeDouble}, Async: true}, "Sum", true, true, "Float64ObservableUpDownCounter", true},
32 {&Histogram{}, "Histogram", true, false, "Histogram", false},
33 } {
34 assert.Equal(t, arg.wantType, arg.metricData.Type())
35 assert.Equal(t, arg.wantHasAggregated, arg.metricData.HasAggregated())
36 assert.Equal(t, arg.wantHasMonotonic, arg.metricData.HasMonotonic())
37 assert.Equal(t, arg.wantInstrument, arg.metricData.Instrument())
38 assert.Equal(t, arg.wantAsync, arg.metricData.IsAsync())
39 }
40 }