mirror of
https://github.com/labstack/echo.git
synced 2024-12-26 20:54:00 +02:00
94e5936287
Signed-off-by: Vishal Rana <vishal.rana@verizon.com>
33 lines
596 B
Go
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,
|
|
}
|
|
}
|