Commit cf752367 authored by Pawel Chojnacki's avatar Pawel Chojnacki

fix tests to work with go 1.8

parent 2aae7003
......@@ -65,6 +65,12 @@ func AssertResponseBody(t *testing.T, response *httptest.ResponseRecorder, expec
}
}
func AssertResponseBodyRegexp(t *testing.T, response *httptest.ResponseRecorder, expectedBody *regexp.Regexp) {
if !expectedBody.MatchString(response.Body.String()) {
t.Fatalf("for HTTP request expected to receive body matching %q, got %q instead", expectedBody.String(), response.Body.String())
}
}
func AssertResponseHeader(t *testing.T, w http.ResponseWriter, header string, expected ...string) {
actual := w.Header()[http.CanonicalHeaderKey(header)]
......
......@@ -83,7 +83,7 @@ func TestProxyError(t *testing.T) {
w := httptest.NewRecorder()
newProxy("http://localhost:655575/", nil).ServeHTTP(w, httpRequest)
testhelper.AssertResponseCode(t, w, 502)
testhelper.AssertResponseBody(t, w, "dial tcp: invalid port 655575")
testhelper.AssertResponseBodyRegexp(t, w, regexp.MustCompile("dial tcp:.*invalid port.*"))
}
func TestProxyReadTimeout(t *testing.T) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment