## Pull Request template Please, go through these steps before clicking submit on this PR. 1. Give a descriptive title to your PR. 2. Provide a description of your changes. 3. Make sure you have some relevant tests. 4. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable). **PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING** Reviewed-on: #398 Co-authored-by: Evstigneev Denis <danteevstigneev@yandex.ru> Co-committed-by: Evstigneev Denis <danteevstigneev@yandex.ru>
34 lines
597 B
Go
34 lines
597 B
Go
package requestid
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"go.unistack.org/micro/v4/metadata"
|
|
)
|
|
|
|
func TestDefaultMetadataFunc(t *testing.T) {
|
|
ctx := context.TODO()
|
|
|
|
nctx, err := DefaultMetadataFunc(ctx)
|
|
if err != nil {
|
|
t.Fatalf("%v", err)
|
|
}
|
|
|
|
imd, ok := metadata.FromIncomingContext(nctx)
|
|
if !ok {
|
|
t.Fatalf("md missing in incoming context")
|
|
}
|
|
omd, ok := metadata.FromOutgoingContext(nctx)
|
|
if !ok {
|
|
t.Fatalf("md missing in outgoing context")
|
|
}
|
|
|
|
_, iok := imd.Get(DefaultMetadataKey)
|
|
_, ook := omd.Get(DefaultMetadataKey)
|
|
|
|
if !iok || !ook {
|
|
t.Fatalf("missing metadata key value")
|
|
}
|
|
}
|