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
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
@ -26,7 +26,7 @@ func TestAppInfo(t *testing.T) {
assert.Equal(t, "tapp", res.Header.Get("App-Name"))
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.Equal(t, "resp", string(b))
}

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ package logger
import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strings"
@ -40,7 +40,7 @@ func TestLogger(t *testing.T) {
defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode)
b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
assert.NoError(t, err)
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) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
assert.NoError(t, err)
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) {
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.Equal(t, "body|password", string(body))

View File

@ -1,7 +1,7 @@
package middleware
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
@ -37,7 +37,7 @@ func TestNoCache(t *testing.T) {
assert.Equal(t, "no-cache", res.Header.Get("Pragma"))
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.Equal(t, "resp", string(b))
}

View File

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

View File

@ -1,7 +1,7 @@
package ratelimit
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"strconv"
@ -101,7 +101,7 @@ func TestRateLimitHeaders(t *testing.T) {
assert.NoError(t, err)
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.Equal(t, "resp", string(b))
@ -116,7 +116,7 @@ func TestRateLimitHeaders(t *testing.T) {
assert.NoError(t, err)
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.Equal(t, "Too Many Requests\n", string(b))
}

View File

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

View File

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

View File

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

View File

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