Debian Codegraph @

pdata/internal/otlp/metrics_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package otlp
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10
11 "go.opentelemetry.io/collector/pdata/internal"
12 )
13
14 func TestDeprecatedScopeMetrics(t *testing.T) {
15 sm := new(internal.ScopeMetrics)
16 rms := []*internal.ResourceMetrics{
17 {
18 ScopeMetrics: []*internal.ScopeMetrics{sm},
19 DeprecatedScopeMetrics: []*internal.ScopeMetrics{sm},
20 },
21 {
22 ScopeMetrics: []*internal.ScopeMetrics{},
23 DeprecatedScopeMetrics: []*internal.ScopeMetrics{sm},
24 },
25 }
26
27 MigrateMetrics(rms)
28 assert.Same(t, sm, rms[0].ScopeMetrics[0])
29 assert.Same(t, sm, rms[1].ScopeMetrics[0])
30 assert.Nil(t, rms[0].DeprecatedScopeMetrics)
31 assert.Nil(t, rms[0].DeprecatedScopeMetrics)
32 }