Exemple #1
0
func TestRedirectTo(t *testing.T) {

	r := new(testhttp.TestResponseWriter)
	RedirectTo(r, "http://www.stretchr.com", "test")
	assert.Equal(t, "http://www.stretchr.com/test", r.Header().Get("Location"))
	assert.Equal(t, 0, r.StatusCode)

}
Exemple #2
0
func TestSetHttpResponseWriter(t *testing.T) {

	responseWriter := new(http_test.TestResponseWriter)
	testRequest, _ := http.NewRequest("GET", "http://goweb.org/people/123", nil)
	codecService := codecsservices.NewWebCodecService()

	c := NewWebContext(responseWriter, testRequest, codecService)

	responseWriter2 := new(http_test.TestResponseWriter)
	responseWriter2.Header().Set("Something", "true")
	testRequest2, _ := http.NewRequest("PUT", "http://goweb.org/people/123", nil)

	c.SetHttpRequest(testRequest2)
	c.SetHttpResponseWriter(responseWriter2)

	req := c.HttpRequest()
	res := c.HttpResponseWriter()

	assert.Equal(t, &testRequest2, &req)
	assert.Equal(t, responseWriter2, res)

}