mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
Basic metadata retrieval test
This commit is contained in:
parent
fe1fde8c59
commit
bbcbd2a446
28
metadata/metadata_test.go
Normal file
28
metadata/metadata_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func TestMetadataContext(t *testing.T) {
|
||||
md := Metadata{
|
||||
"foo": "bar",
|
||||
}
|
||||
|
||||
ctx := NewContext(context.TODO(), md)
|
||||
|
||||
emd, ok := FromContext(ctx)
|
||||
if !ok {
|
||||
t.Errorf("Unexpected error retrieving metadata, got %t", ok)
|
||||
}
|
||||
|
||||
if emd["foo"] != md["foo"] {
|
||||
t.Errorf("Expected key: %s val: %s, got key: %s val: %s", "foo", md["foo"], "foo", emd["foo"])
|
||||
}
|
||||
|
||||
if i := len(emd); i != 1 {
|
||||
t.Errorf("Expected metadata length 1 got %d", i)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user