From ee56ff4e2797aa6cf2f2215d7c8cf25ca0d417d5 Mon Sep 17 00:00:00 2001 From: anirut Date: Thu, 1 Sep 2022 00:36:53 +0700 Subject: [PATCH] :white_check_mark: add headers testing --- transport/http/calloption_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/transport/http/calloption_test.go b/transport/http/calloption_test.go index 4fe6f3a58..39be878d3 100644 --- a/transport/http/calloption_test.go +++ b/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) + } +}