Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryigithankardas <root>2022-02-17 00:12:48 +0300
committeryigithankardas <root>2022-02-17 00:12:48 +0300
commitd3f469b09283260e388719673653599788dc1d56 (patch)
tree2ca98b499625f961af87c7e7270bcc4aaf2c32e2 /internal
parentd8f645df7f1fb711698ecc31f71b577b3f8dc617 (diff)
revert: revert all the changes on *_test.go files.
Diffstat (limited to 'internal')
-rw-r--r--internal/auth/auth_test.go10
-rw-r--r--internal/httpfs/http_fs_test.go3
-rw-r--r--internal/httptransport/metered_round_tripper_test.go3
-rw-r--r--internal/serving/disk/local/serving_test.go2
-rw-r--r--internal/serving/disk/zip/serving_test.go2
-rw-r--r--internal/urilimiter/urilimiter_test.go3
6 files changed, 9 insertions, 14 deletions
diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go
index 94ffc23b..47e424c1 100644
--- a/internal/auth/auth_test.go
+++ b/internal/auth/auth_test.go
@@ -17,8 +17,6 @@ import (
"gitlab.com/gitlab-org/gitlab-pages/internal/request"
"gitlab.com/gitlab-org/gitlab-pages/internal/source/mock"
-
- "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
)
func createTestAuth(t *testing.T, internalServer string, publicServer string) *Auth {
@@ -70,7 +68,7 @@ func setSessionValues(t *testing.T, r *http.Request, store sessions.Store, value
session.Save(tmpRequest, result)
res := result.Result()
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
for _, cookie := range res.Cookies() {
r.AddCookie(cookie)
@@ -234,7 +232,7 @@ func testTryAuthenticateWithCodeAndState(t *testing.T, https bool) {
require.True(t, auth.TryAuthenticate(result, r, mockSource))
res := result.Result()
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
require.Equal(t, http.StatusFound, result.Code)
require.Equal(t, "https://pages.gitlab-example.com/project/", result.Header().Get("Location"))
@@ -320,7 +318,7 @@ func TestCheckAuthenticationWhenNoAccess(t *testing.T) {
contentServed := auth.CheckAuthentication(w, r, &domainMock{projectID: 1000, notFoundContent: "Generic 404"})
require.True(t, contentServed)
res := w.Result()
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
require.Equal(t, http.StatusNotFound, res.StatusCode)
@@ -495,7 +493,7 @@ func TestCheckResponseForInvalidTokenWhenInvalidToken(t *testing.T) {
r := &http.Request{URL: reqURL, Host: "pages.gitlab-example.com", RequestURI: "/test"}
resp := &http.Response{StatusCode: http.StatusUnauthorized, Body: io.NopCloser(bytes.NewReader([]byte("{\"error\":\"invalid_token\"}")))}
- testhelpers.Close(t, resp.Body)
+ defer resp.Body.Close()
require.True(t, auth.CheckResponseForInvalidToken(result, r, resp))
res := result.Result()
diff --git a/internal/httpfs/http_fs_test.go b/internal/httpfs/http_fs_test.go
index 25003726..991c6017 100644
--- a/internal/httpfs/http_fs_test.go
+++ b/internal/httpfs/http_fs_test.go
@@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-pages/internal/httptransport"
- "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
)
func TestFSOpen(t *testing.T) {
@@ -162,7 +161,7 @@ func TestFileSystemPathCanServeHTTP(t *testing.T) {
res, err := client.Do(req)
require.NoError(t, err)
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
require.Equal(t, test.expectedStatusCode, res.StatusCode)
content, err := io.ReadAll(res.Body)
diff --git a/internal/httptransport/metered_round_tripper_test.go b/internal/httptransport/metered_round_tripper_test.go
index 8a298e20..2b126760 100644
--- a/internal/httptransport/metered_round_tripper_test.go
+++ b/internal/httptransport/metered_round_tripper_test.go
@@ -10,7 +10,6 @@ import (
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
)
func TestReconfigureMeteredRoundTripper(t *testing.T) {
@@ -24,7 +23,7 @@ func TestReconfigureMeteredRoundTripper(t *testing.T) {
res, err := mrt.RoundTrip(r)
require.NoError(t, err)
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
require.Equal(t, http.StatusOK, res.StatusCode)
body, err := io.ReadAll(res.Body)
diff --git a/internal/serving/disk/local/serving_test.go b/internal/serving/disk/local/serving_test.go
index dbb14138..8352bfc9 100644
--- a/internal/serving/disk/local/serving_test.go
+++ b/internal/serving/disk/local/serving_test.go
@@ -79,7 +79,7 @@ func TestDisk_ServeFileHTTP(t *testing.T) {
require.True(t, s.ServeFileHTTP(handler))
resp := w.Result()
- testhelpers.Close(t, resp.Body)
+ defer resp.Body.Close()
require.Equal(t, test.expectedStatus, resp.StatusCode)
body, err := io.ReadAll(resp.Body)
diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go
index c3b18f2b..2b603b5d 100644
--- a/internal/serving/disk/zip/serving_test.go
+++ b/internal/serving/disk/zip/serving_test.go
@@ -209,7 +209,7 @@ func TestZip_ServeFileHTTP(t *testing.T) {
require.True(t, s.ServeFileHTTP(handler))
resp := w.Result()
- testhelpers.Close(t, resp.Body)
+ defer resp.Body.Close()
require.Equal(t, test.expectedStatus, resp.StatusCode)
body, err := io.ReadAll(resp.Body)
diff --git a/internal/urilimiter/urilimiter_test.go b/internal/urilimiter/urilimiter_test.go
index a314ec91..0ac89ea0 100644
--- a/internal/urilimiter/urilimiter_test.go
+++ b/internal/urilimiter/urilimiter_test.go
@@ -8,7 +8,6 @@ import (
"testing"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitlab-pages/internal/testhelpers"
)
func TestNewMiddleware(t *testing.T) {
@@ -57,7 +56,7 @@ func TestNewMiddleware(t *testing.T) {
middleware.ServeHTTP(ww, rr)
res := ww.Result()
- testhelpers.Close(t, res.Body)
+ defer res.Body.Close()
require.Equal(t, tt.expectedStatus, res.StatusCode)
if tt.expectedStatus == http.StatusOK {