1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-26 20:54:00 +02:00
echo/test/http.go
Vishal Rana 94e5936287 Fixed test cases
Signed-off-by: Vishal Rana <vishal.rana@verizon.com>
2016-02-09 19:07:04 -08:00

33 lines
596 B
Go

package test
import (
"bytes"
"io"
"net/http"
"net/http/httptest"
"github.com/labstack/echo/engine"
"github.com/labstack/echo/engine/standard"
"github.com/labstack/gommon/log"
)
type (
ResponseRecorder struct {
engine.Response
Body *bytes.Buffer
}
)
func NewRequest(method, url string, body io.Reader) engine.Request {
r, _ := http.NewRequest(method, url, body)
return standard.NewRequest(r)
}
func NewResponseRecorder() *ResponseRecorder {
r := httptest.NewRecorder()
return &ResponseRecorder{
Response: standard.NewResponse(r, log.New("test")),
Body: r.Body,
}
}