1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00
go-micro/metadata/metadata_test.go
2018-03-03 11:53:52 +00:00

28 lines
491 B
Go

package metadata
import (
"context"
"testing"
)
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)
}
}