mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #114426 from my-git9/ut/request_
[UT] add test for pkg/probe/http/request.go
This commit is contained in:
commit
78fe7c0dbc
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user