fix: update linter.
This commit is contained in:
parent
027d313df5
commit
29efac3e5e
52 changed files with 17 additions and 89 deletions
|
@ -45,7 +45,6 @@ func AddServiceFields(rw http.ResponseWriter, req *http.Request, next http.Handl
|
|||
data.Core[ServiceAddr] = req.URL.Host
|
||||
|
||||
next.ServeHTTP(rw, req)
|
||||
|
||||
}
|
||||
|
||||
// AddOriginFields add origin fields
|
||||
|
|
|
@ -69,8 +69,8 @@ func toLog(fields logrus.Fields, key string, defaultValue string, quoted bool) i
|
|||
return v
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func toLogEntry(s string, defaultValue string, quote bool) string {
|
||||
|
|
|
@ -99,11 +99,9 @@ func TestCommonLogFormatter_Format(t *testing.T) {
|
|||
assert.Equal(t, test.expectedLog, string(raw))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func Test_toLog(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
fields logrus.Fields
|
||||
|
|
|
@ -527,7 +527,6 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
|
|||
for _, test := range testCases {
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
// NOTE: It is not possible to run these cases in parallel because we capture Stdout
|
||||
|
||||
file, restoreStdout := captureStdout(t)
|
||||
|
@ -543,7 +542,6 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
|
|||
}
|
||||
|
||||
func assertValidLogData(t *testing.T, expected string, logData []byte) {
|
||||
|
||||
if len(expected) == 0 {
|
||||
assert.Zero(t, len(logData))
|
||||
t.Log(string(logData))
|
||||
|
|
|
@ -367,7 +367,6 @@ func Test_writeHeader(t *testing.T) {
|
|||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
req := testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar/path?q=1", nil)
|
||||
for key, value := range test.headers {
|
||||
req.Header.Set(key, value)
|
||||
|
|
|
@ -327,7 +327,6 @@ func TestGetTracingInformation(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "testing", name)
|
||||
assert.Equal(t, tracing.SpanKindNoneEnum, trace)
|
||||
|
||||
}
|
||||
|
||||
func TestCORSResponses(t *testing.T) {
|
||||
|
|
|
@ -360,7 +360,6 @@ WqeUSNGYV//RunTeuRDAf5OxehERb1srzBXhRZ3cZdzXbgR/`),
|
|||
require.Equal(t, test.expected, sanitize(test.toSanitize), "The sanitized certificates should be equal")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestTLSClientHeadersWithPEM(t *testing.T) {
|
||||
|
@ -429,7 +428,6 @@ func TestTLSClientHeadersWithPEM(t *testing.T) {
|
|||
require.Empty(t, res.Header().Get(xForwardedTLSClientCert), "The response header should be always empty")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGetSans(t *testing.T) {
|
||||
|
@ -478,7 +476,6 @@ func TestGetSans(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestTLSClientHeadersWithCertInfo(t *testing.T) {
|
||||
|
@ -659,5 +656,4 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
|
|||
require.Empty(t, res.Header().Get(xForwardedTLSClientCertInfo), "The response header should be always empty")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ func (p *pipelining) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
p.next.ServeHTTP(&writerWithoutCloseNotify{rw}, r)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// writerWithoutCloseNotify helps to disable closeNotify
|
||||
|
|
|
@ -142,7 +142,6 @@ func TestRateLimit(t *testing.T) {
|
|||
for _, test := range testCases {
|
||||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
t.Parallel()
|
||||
|
||||
reqCount := 0
|
||||
|
|
|
@ -179,16 +179,13 @@ func TestRedirectRegexHandler(t *testing.T) {
|
|||
handler.ServeHTTP(recorder, r)
|
||||
|
||||
assert.Equal(t, test.expectedStatus, recorder.Code)
|
||||
if test.expectedStatus == http.StatusMovedPermanently ||
|
||||
test.expectedStatus == http.StatusFound ||
|
||||
test.expectedStatus == http.StatusTemporaryRedirect ||
|
||||
test.expectedStatus == http.StatusPermanentRedirect {
|
||||
|
||||
switch test.expectedStatus {
|
||||
case http.StatusMovedPermanently, http.StatusFound, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
|
||||
location, err := recorder.Result().Location()
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, test.expectedURL, location.String())
|
||||
} else {
|
||||
default:
|
||||
location, err := recorder.Result().Location()
|
||||
require.Errorf(t, err, "Location %v", location)
|
||||
}
|
||||
|
|
|
@ -206,16 +206,14 @@ func TestRedirectSchemeHandler(t *testing.T) {
|
|||
handler.ServeHTTP(recorder, r)
|
||||
|
||||
assert.Equal(t, test.expectedStatus, recorder.Code)
|
||||
if test.expectedStatus == http.StatusMovedPermanently ||
|
||||
test.expectedStatus == http.StatusFound ||
|
||||
test.expectedStatus == http.StatusTemporaryRedirect ||
|
||||
test.expectedStatus == http.StatusPermanentRedirect {
|
||||
|
||||
switch test.expectedStatus {
|
||||
case http.StatusMovedPermanently, http.StatusFound, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
|
||||
location, err := recorder.Result().Location()
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, test.expectedURL, location.String())
|
||||
} else {
|
||||
default:
|
||||
location, err := recorder.Result().Location()
|
||||
require.Errorf(t, err, "Location %v", location)
|
||||
}
|
||||
|
@ -234,7 +232,6 @@ func TestRedirectSchemeHandler(t *testing.T) {
|
|||
test.expectedStatus == http.StatusFound ||
|
||||
test.expectedStatus == http.StatusTemporaryRedirect ||
|
||||
test.expectedStatus == http.StatusPermanentRedirect {
|
||||
|
||||
location, err := recorder.Result().Location()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ func TestReplacePath(t *testing.T) {
|
|||
|
||||
for _, path := range paths {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
|
||||
var expectedPath, actualHeader, requestURI string
|
||||
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
expectedPath = r.URL.Path
|
||||
|
|
|
@ -74,7 +74,6 @@ func TestReplacePathRegex(t *testing.T) {
|
|||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
var actualPath, actualHeader, requestURI string
|
||||
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
actualPath = r.URL.Path
|
||||
|
|
|
@ -65,7 +65,6 @@ func TestEntryPointMiddleware(t *testing.T) {
|
|||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ func TestNewForwarder(t *testing.T) {
|
|||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue