You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-25 22:41:46 +02:00
Add MapCarrier (#2334)
* Add MapCarrier * Update CHANGELOG.md * Lint propagation_test.go * Remove trailing space in changelog entry * Revert change to internal/tools/go.sum
This commit is contained in:
@@ -16,9 +16,12 @@ package propagation_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
)
|
||||
|
||||
@@ -102,3 +105,33 @@ func TestCompositeTextMapPropagatorExtract(t *testing.T) {
|
||||
t.Errorf("invalid extract order: %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapCarrierGet(t *testing.T) {
|
||||
carrier := propagation.MapCarrier{
|
||||
"foo": "bar",
|
||||
"baz": "qux",
|
||||
}
|
||||
|
||||
assert.Equal(t, carrier.Get("foo"), "bar")
|
||||
assert.Equal(t, carrier.Get("baz"), "qux")
|
||||
}
|
||||
|
||||
func TestMapCarrierSet(t *testing.T) {
|
||||
carrier := make(propagation.MapCarrier)
|
||||
carrier.Set("foo", "bar")
|
||||
carrier.Set("baz", "qux")
|
||||
|
||||
assert.Equal(t, carrier["foo"], "bar")
|
||||
assert.Equal(t, carrier["baz"], "qux")
|
||||
}
|
||||
|
||||
func TestMapCarrierKeys(t *testing.T) {
|
||||
carrier := propagation.MapCarrier{
|
||||
"foo": "bar",
|
||||
"baz": "qux",
|
||||
}
|
||||
|
||||
keys := carrier.Keys()
|
||||
sort.Strings(keys)
|
||||
assert.Equal(t, []string{"baz", "foo"}, keys)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user