diff --git a/pkg/probe/http/request_test.go b/pkg/probe/http/request_test.go index 9a05eb556fb..77c3d919596 100644 --- a/pkg/probe/http/request_test.go +++ b/pkg/probe/http/request_test.go @@ -16,7 +16,13 @@ limitations under the License. package http -import "testing" +import ( + "net/http" + "reflect" + "testing" + + v1 "k8s.io/api/core/v1" +) func TestFormatURL(t *testing.T) { testCases := []struct { @@ -38,3 +44,37 @@ func TestFormatURL(t *testing.T) { } } } + +func Test_v1HeaderToHTTPHeader(t *testing.T) { + tests := []struct { + name string + headerList []v1.HTTPHeader + want http.Header + }{ + { + name: "not empty input", + headerList: []v1.HTTPHeader{ + {Name: "Connection", Value: "Keep-Alive"}, + {Name: "Content-Type", Value: "text/html"}, + {Name: "Accept-Ranges", Value: "bytes"}, + }, + want: http.Header{ + "Connection": {"Keep-Alive"}, + "Content-Type": {"text/html"}, + "Accept-Ranges": {"bytes"}, + }, + }, + { + name: "empty input", + headerList: []v1.HTTPHeader{}, + want: http.Header{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := v1HeaderToHTTPHeader(tt.headerList); !reflect.DeepEqual(got, tt.want) { + t.Errorf("v1HeaderToHTTPHeader() = %v, want %v", got, tt.want) + } + }) + } +}