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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-05 19:04:21 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-05 19:04:21 +0300
commitb0ac2a7d3f7c48702120de4910cde34b7aee7bdd (patch)
treea8aaad3f80b5dcf51f2d3e8905d5da1172784c07 /domain_test.go
parent5c830cca6dee4ad6f0025dda14fa345bb677e38c (diff)
Fix: Content-Type of predefined 404 pagev0.2.2
Diffstat (limited to 'domain_test.go')
-rw-r--r--domain_test.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/domain_test.go b/domain_test.go
index d1dca06e..56e032a4 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -5,6 +5,9 @@ import (
"net/http"
"net/url"
"testing"
+ "net/http/httptest"
+ "github.com/stretchr/testify/require"
+ "mime"
)
func TestGroupServeHTTP(t *testing.T) {
@@ -48,14 +51,16 @@ func TestDomainServeHTTP(t *testing.T) {
assert.HTTPError(t, testDomain.ServeHTTP, "GET", "/not-existing-file", nil)
}
-func testHTTP404(t *testing.T, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) bool {
- if !assert.HTTPError(t, handler, mode, url, values) {
- return false
- }
- if !assert.HTTPBodyContains(t, handler, mode, url, values, str) {
- return false
- }
- return true
+func testHTTP404(t *testing.T, handler http.HandlerFunc, mode, url string, values url.Values, str interface{}) {
+ w := httptest.NewRecorder()
+ req, err := http.NewRequest(mode, url+"?"+values.Encode(), nil)
+ require.NoError(t, err)
+ handler(w, req)
+
+ contentType, _, _ := mime.ParseMediaType(w.Header().Get("Content-Type"))
+ assert.Equal(t, http.StatusNotFound, w.Code, "HTTP status")
+ assert.Equal(t, "text/html", contentType, "Content-Type")
+ assert.Contains(t, w.Body.String(), str)
}
func TestGroup404ServeHTTP(t *testing.T) {