-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[opentracing] add SpanContext implementation
- Loading branch information
Emanuele Palazzetti
committed
Dec 1, 2017
1 parent
8d966a0
commit 00e7898
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package opentracing | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSpanContextBaggage(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
ctx := SpanContext{} | ||
ctx = ctx.WithBaggageItem("key", "value") | ||
assert.Equal("value", ctx.baggage["key"]) | ||
} | ||
|
||
func TestSpanContextIterator(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
baggageIterator := make(map[string]string) | ||
ctx := SpanContext{baggage: map[string]string{"key": "value"}} | ||
ctx.ForeachBaggageItem(func(k, v string) bool { | ||
baggageIterator[k] = v | ||
return true | ||
}) | ||
|
||
assert.Len(baggageIterator, 1) | ||
assert.Equal("value", baggageIterator["key"]) | ||
} |