Skip to content

Commit

Permalink
Add test for textMapAdapter.Keys
Browse files Browse the repository at this point in the history
This is not currently used in normal functioning of Inject and Extract,
but might get used in future so give it some testing now.

Test adapted from `open-telemetry/opentelemetry-go/propagation/propagation_test.go`

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Apr 18, 2022
1 parent fcb9b2a commit 19a7594
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bridge/opentracing/bridge_test.go
Expand Up @@ -16,14 +16,31 @@ package opentracing

import (
"reflect"
"sort"
"testing"

ot "github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/bridge/opentracing/internal"
"go.opentelemetry.io/otel/propagation"
)

func TestTextMapAdapterKeys(t *testing.T) {
carrier := ot.TextMapCarrier{
"foo": "bar",
"baz": "qux",
}

keys := textMapAdapter{r: carrier}.Keys()
sort.Strings(keys)
assert.Equal(t, []string{"baz", "foo"}, keys)

// Check what happens if we read from a write-capable adaptor.
keys = textMapAdapter{w: carrier}.Keys()
assert.Nil(t, keys)
}

func TestMapCarrier(t *testing.T) {
carrier := propagation.MapCarrier{}
testBridgeWithCarrier(t, carrier)
Expand Down

0 comments on commit 19a7594

Please sign in to comment.