test(transport) add headers testing

pull/2344/head
anirut 2 years ago
parent 6c1381a8a7
commit a3a245342f
  1. 27
      transport/http/calloption_test.go

@ -96,3 +96,30 @@ func TestHeaderCallOption_after(t *testing.T) {
t.Errorf("want: %v,got: %v", &h, o.(HeaderCallOption).header)
}
}
func TestHeaders(t *testing.T) {
if !reflect.DeepEqual(map[string]string{
"trace_id": "xxxx",
}, Headers(map[string]string{
"trace_id": "xxxx",
}).(HeadersCallOption).headers) {
t.Errorf("want: %v,got: %v", "{'trace_id': 'xxxx'}", Headers(map[string]string{
"trace_id": "xxxx",
}).(HeadersCallOption).headers)
}
}
func TestHeadersCallOption_before(t *testing.T) {
c := &callInfo{}
err := Headers(map[string]string{
"trace_id": "xxxx",
}).before(c)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(map[string]string{
"trace_id": "xxxx",
}, c.headers) {
t.Errorf("want: %v, got: %v", "{'trace_id': 'xxxx'}", c.headers)
}
}

Loading…
Cancel
Save