You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
80cb909774
Based on the Go version we currently use, the dependency already supports 1.24+, which allows using `t.Context()` and `b.Context()` in unit tests and benchmarks respectively. - Enable `context-background` and `context-todo` in [`usetesting`](https://golangci-lint.run/docs/linters/configuration/#usetesting) - Adjust the code to support linter detection --------- Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com> Co-authored-by: Tyler Yahn <codingalias@gmail.com> Co-authored-by: Damien Mathieu <42@dmathieu.com>
25 lines
528 B
Go
25 lines
528 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package baggage
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"go.opentelemetry.io/otel/internal/baggage"
|
|
)
|
|
|
|
func TestContext(t *testing.T) {
|
|
ctx := t.Context()
|
|
assert.Equal(t, Baggage{}, FromContext(ctx))
|
|
|
|
b := Baggage{list: baggage.List{"key": baggage.Item{Value: "val"}}}
|
|
ctx = ContextWithBaggage(ctx, b)
|
|
assert.Equal(t, b, FromContext(ctx))
|
|
|
|
ctx = ContextWithoutBaggage(ctx)
|
|
assert.Equal(t, Baggage{}, FromContext(ctx))
|
|
}
|