micro-wrapper-requestid/requestid_test.go
Vasiliy Tolstov bd6ebc31d6
Some checks failed
build / test (push) Failing after 1m18s
codeql / analyze (go) (push) Failing after 2m24s
build / lint (push) Successful in 9m24s
optimize
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-03-10 22:14:28 +03:00

38 lines
669 B
Go

package requestid
import (
"context"
"testing"
"go.unistack.org/micro/v4/metadata"
)
func TestDefaultMetadataFunc(t *testing.T) {
ctx := context.TODO()
var err error
ctx, err = DefaultMetadataFunc(ctx)
if err != nil {
t.Fatalf("%v", err)
}
imd, ok := metadata.FromIncomingContext(ctx)
if !ok {
t.Fatalf("md missing in incoming context")
}
omd, ok := metadata.FromOutgoingContext(ctx)
if !ok {
t.Fatalf("md missing in outgoing context")
}
iv, iok := imd.Get(DefaultMetadataKey)
ov, ook := omd.Get(DefaultMetadataKey)
if !iok || !ook {
t.Fatalf("missing metadata key value")
}
if iv != ov {
t.Fatalf("invalid metadata key value")
}
}