Code cleanup for for probe/http
Two small code cleanup changes for `probe/http`. - Tests name the `followNonLocalRedirects` variable before passing to `New`, so its clear what the boolean flag in the construct impacts. - Change import name from `httprobe` to `httpprobe` when used by `pkg/kubelet/prober/prober.go`. Establishes consistency with other uses in the repo.
This commit is contained in:
@@ -67,7 +67,8 @@ func TestHTTPProbeProxy(t *testing.T) {
|
||||
defer unsetEnv("no_proxy")()
|
||||
defer unsetEnv("NO_PROXY")()
|
||||
|
||||
prober := New(true)
|
||||
followNonLocalRedirects := true
|
||||
prober := New(followNonLocalRedirects)
|
||||
|
||||
go func() {
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -122,7 +123,8 @@ func TestHTTPProbeChecker(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
prober := New(true)
|
||||
followNonLocalRedirects := true
|
||||
prober := New(followNonLocalRedirects)
|
||||
testCases := []struct {
|
||||
handler func(w http.ResponseWriter, r *http.Request)
|
||||
reqHeaders http.Header
|
||||
@@ -299,14 +301,16 @@ func TestHTTPProbeChecker_NonLocalRedirects(t *testing.T) {
|
||||
}
|
||||
for desc, test := range testCases {
|
||||
t.Run(desc+"-local", func(t *testing.T) {
|
||||
prober := New(false)
|
||||
followNonLocalRedirects := false
|
||||
prober := New(followNonLocalRedirects)
|
||||
target, err := url.Parse(server.URL + "/redirect?loc=" + url.QueryEscape(test.redirect))
|
||||
require.NoError(t, err)
|
||||
result, _, _ := prober.Probe(target, nil, wait.ForeverTestTimeout)
|
||||
assert.Equal(t, test.expectLocalResult, result)
|
||||
})
|
||||
t.Run(desc+"-nonlocal", func(t *testing.T) {
|
||||
prober := New(true)
|
||||
followNonLocalRedirects := true
|
||||
prober := New(followNonLocalRedirects)
|
||||
target, err := url.Parse(server.URL + "/redirect?loc=" + url.QueryEscape(test.redirect))
|
||||
require.NoError(t, err)
|
||||
result, _, _ := prober.Probe(target, nil, wait.ForeverTestTimeout)
|
||||
|
Reference in New Issue
Block a user