1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00
Files
opentelemetry-go/sdk/metric/internal/x/x_test.go
Yevhenii Solomchenko 5a046207d2 sdk/metric: Deprecate the sdk/metric/x Feature Supporting Cardinality Limits (#7166)
Fixes #6980
Towards #6887

## What

- Any references to sdk/metric/x in documentation, tests, or examples
are updated to redirect users to use the cardinality limit feature in
the SDK.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2025-08-12 09:29:54 +02:00

52 lines
989 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package x
import (
"testing"
"github.com/stretchr/testify/assert"
)
//nolint:unused
func run(steps ...func(*testing.T)) func(*testing.T) {
return func(t *testing.T) {
t.Helper()
for _, step := range steps {
step(t)
}
}
}
//nolint:unused
func setenv(k, v string) func(t *testing.T) {
return func(t *testing.T) { t.Setenv(k, v) }
}
//nolint:unused
func assertEnabled[T any](f Feature[T], want T) func(*testing.T) {
return func(t *testing.T) {
t.Helper()
assert.True(t, f.Enabled(), "not enabled")
v, ok := f.Lookup()
assert.True(t, ok, "Lookup state")
assert.Equal(t, want, v, "Lookup value")
}
}
//nolint:unused
func assertDisabled[T any](f Feature[T]) func(*testing.T) {
var zero T
return func(t *testing.T) {
t.Helper()
assert.False(t, f.Enabled(), "enabled")
v, ok := f.Lookup()
assert.False(t, ok, "Lookup state")
assert.Equal(t, zero, v, "Lookup value")
}
}