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:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2021-12-08 16:27:44 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2022-01-14 14:57:39 +0300
commita5c896d1aa4f672ec46778b9f98c7850a38bc94c (patch)
tree177f574f9cc782f450983e4b073911448144089a /internal/domain
parenta7e130776d934a12ab000bee930c5c353b772635 (diff)
test: replace http status assertions with testify method
Diffstat (limited to 'internal/domain')
-rw-r--r--internal/domain/domain_test.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/internal/domain/domain_test.go b/internal/domain/domain_test.go
index d76e10e8..57b8f185 100644
--- a/internal/domain/domain_test.go
+++ b/internal/domain/domain_test.go
@@ -2,9 +2,7 @@ package domain
import (
"fmt"
- "io"
"net/http"
- "net/http/httptest"
"testing"
"github.com/stretchr/testify/require"
@@ -92,7 +90,8 @@ func TestPredefined404ServeHTTP(t *testing.T) {
testDomain := New("", "", "", &stubbedResolver{err: ErrDomainDoesNotExist})
- testhelpers.AssertHTTP404(t, serveFileOrNotFound(testDomain), "GET", "http://group.test.io/not-existing-file", nil, "The page you're looking for could not be found")
+ require.HTTPStatusCode(t, serveFileOrNotFound(testDomain), http.MethodGet, "http://group.test.io/not-existing-file", nil, http.StatusNotFound)
+ require.HTTPBodyContains(t, serveFileOrNotFound(testDomain), http.MethodGet, "http://group.test.io/not-existing-file", nil, "The page you're looking for could not be found")
}
func TestGroupCertificate(t *testing.T) {
@@ -204,18 +203,9 @@ func TestServeNamespaceNotFound(t *testing.T) {
Name: tt.domain,
Resolver: tt.resolver,
}
- w := httptest.NewRecorder()
- r := httptest.NewRequest("GET", fmt.Sprintf("http://%s%s", tt.domain, tt.path), nil)
- d.serveNamespaceNotFound(w, r)
- resp := w.Result()
- defer resp.Body.Close()
-
- require.Equal(t, http.StatusNotFound, resp.StatusCode)
- body, err := io.ReadAll(resp.Body)
- require.NoError(t, err)
-
- require.Contains(t, string(body), tt.expectedResponse)
+ require.HTTPStatusCode(t, d.serveNamespaceNotFound, http.MethodGet, fmt.Sprintf("http://%s%s", tt.domain, tt.path), nil, http.StatusNotFound)
+ require.HTTPBodyContains(t, d.serveNamespaceNotFound, http.MethodGet, fmt.Sprintf("http://%s%s", tt.domain, tt.path), nil, tt.expectedResponse)
})
}
}