Fix lint errors

This commit is contained in:
Anton Zadvorny 2023-12-25 03:47:12 +03:00
parent 890684e7b1
commit 5a4fe6a63f
13 changed files with 34 additions and 34 deletions

View File

@ -1,7 +1,7 @@
package middleware package middleware
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -26,7 +26,7 @@ func TestAppInfo(t *testing.T) {
assert.Equal(t, "tapp", res.Header.Get("App-Name")) assert.Equal(t, "tapp", res.Header.Get("App-Name"))
assert.Equal(t, "tversion", res.Header.Get("App-Version")) assert.Equal(t, "tversion", res.Header.Get("App-Version"))
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }

View File

@ -1,7 +1,7 @@
package jwt package jwt
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -36,7 +36,7 @@ func TestJWTAuthDefaults(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusUnauthorized, res.StatusCode) assert.Equal(t, http.StatusUnauthorized, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "Unauthorized\n", string(b)) assert.Equal(t, "Unauthorized\n", string(b))
@ -49,7 +49,7 @@ func TestJWTAuthDefaults(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err = ioutil.ReadAll(res.Body) b, err = io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }

View File

@ -1,7 +1,7 @@
package token package token
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -34,7 +34,7 @@ func TestTokenAuthDefaults(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusUnauthorized, res.StatusCode) assert.Equal(t, http.StatusUnauthorized, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "Unauthorized\n", string(b)) assert.Equal(t, "Unauthorized\n", string(b))
@ -62,7 +62,7 @@ func TestTokenAuthValidateFn(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }

View File

@ -2,7 +2,7 @@ package logger
import ( import (
"errors" "errors"
"io/ioutil" "io"
"strings" "strings"
"testing" "testing"
@ -39,7 +39,7 @@ func TestLoggerPeek(t *testing.T) {
continue continue
} }
body, err := ioutil.ReadAll(r) body, err := io.ReadAll(r)
if !assert.NoError(t, err) { if !assert.NoError(t, err) {
continue continue
} }

View File

@ -1,7 +1,7 @@
package logger package logger
import ( import (
"io/ioutil" "io"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
@ -110,7 +110,7 @@ func (s *logger) body(r *http.Request) string {
return "" return ""
} }
r.Body = ioutil.NopCloser(rdr) r.Body = io.NopCloser(rdr)
if len(body) > 0 { if len(body) > 0 {
body = strings.ReplaceAll(body, "\n", " ") body = strings.ReplaceAll(body, "\n", " ")

View File

@ -2,7 +2,7 @@ package logger
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
@ -40,7 +40,7 @@ func TestLogger(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }
@ -57,7 +57,7 @@ func TestLoggerBody(t *testing.T) {
) )
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body, err := ioutil.ReadAll(r.Body) body, err := io.ReadAll(r.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "12345678901234567890", string(body)) assert.Equal(t, "12345678901234567890", string(body))
@ -116,7 +116,7 @@ func TestLoggerSanitize(t *testing.T) {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, r.URL.Query().Get("param"), "password") assert.Equal(t, r.URL.Query().Get("param"), "password")
body, err := ioutil.ReadAll(r.Body) body, err := io.ReadAll(r.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "body|password", string(body)) assert.Equal(t, "body|password", string(body))

View File

@ -1,7 +1,7 @@
package middleware package middleware
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -37,7 +37,7 @@ func TestNoCache(t *testing.T) {
assert.Equal(t, "no-cache", res.Header.Get("Pragma")) assert.Equal(t, "no-cache", res.Header.Get("Pragma"))
assert.Equal(t, "0", res.Header.Get("X-Accel-Expires")) assert.Equal(t, "0", res.Header.Get("X-Accel-Expires"))
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }

View File

@ -1,7 +1,7 @@
package middleware package middleware
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -24,7 +24,7 @@ func TestPing(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
@ -33,7 +33,7 @@ func TestPing(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err = ioutil.ReadAll(res.Body) b, err = io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "pong", string(b)) assert.Equal(t, "pong", string(b))
@ -42,7 +42,7 @@ func TestPing(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err = ioutil.ReadAll(res.Body) b, err = io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "pong", string(b)) assert.Equal(t, "pong", string(b))
} }

View File

@ -1,7 +1,7 @@
package ratelimit package ratelimit
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strconv" "strconv"
@ -101,7 +101,7 @@ func TestRateLimitHeaders(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1) assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
@ -116,7 +116,7 @@ func TestRateLimitHeaders(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1) assert.InDelta(t, now.Add(time.Minute*1).Unix(), resetTS, 1)
b, err = ioutil.ReadAll(res.Body) b, err = io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "Too Many Requests\n", string(b)) assert.Equal(t, "Too Many Requests\n", string(b))
} }

View File

@ -1,7 +1,7 @@
package middleware package middleware
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
@ -35,7 +35,7 @@ func TestRealIPXRealIP(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }

View File

@ -1,7 +1,7 @@
package recoverer package recoverer
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -47,7 +47,7 @@ func TestRecoverer(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))

View File

@ -1,7 +1,7 @@
package throttle package throttle
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"sync" "sync"
@ -43,7 +43,7 @@ func TestThrottleBacklog(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
}() }()
@ -170,7 +170,7 @@ func TestThrottleMaximum(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
}() }()

View File

@ -1,7 +1,7 @@
package timeout package timeout
import ( import (
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"testing" "testing"
@ -32,7 +32,7 @@ func TestTimeoutPass(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body) b, err := io.ReadAll(res.Body)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "resp", string(b)) assert.Equal(t, "resp", string(b))
} }