Debian Codegraph @

baggage/context_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package baggage
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10
11 "go.opentelemetry.io/otel/internal/baggage"
12 )
13
14 func TestContext(t *testing.T) {
15 ctx := t.Context()
16 assert.Equal(t, Baggage{}, FromContext(ctx))
17
18 b := Baggage{list: baggage.List{"key": baggage.Item{Value: "val"}}}
19 ctx = ContextWithBaggage(ctx, b)
20 assert.Equal(t, b, FromContext(ctx))
21
22 ctx = ContextWithoutBaggage(ctx)
23 assert.Equal(t, Baggage{}, FromContext(ctx))
24 }