github.com/seeker-insurance/kit@v0.0.13/web/testing/deprecated.go (about) 1 package testing 2 3 import ( 4 "net/http/httptest" 5 "strings" 6 7 "github.com/labstack/echo" 8 ) 9 10 type EchoTest struct { 11 Echo *echo.Echo 12 } 13 14 func (e *EchoTest) TestPost(url string, json *string) (echo.Context, *httptest.ResponseRecorder) { 15 req := httptest.NewRequest(echo.POST, url, strings.NewReader(*json)) 16 req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) 17 rec := httptest.NewRecorder() 18 ctx := e.Echo.NewContext(req, rec) 19 return ctx, rec 20 } 21 22 // func TestPost(url string, json *string) (echo.Context, *httptest.ResponseRecorder) { 23 // req := httptest.NewRequest(echo.POST, url, strings.NewReader(*json)) 24 // req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) 25 // rec := httptest.NewRecorder() 26 // ctx := e.NewContext(req, rec) 27 // return ctx, rec 28 // } 29 30 // func TestGet(url string) (echo.Context, *httptest.ResponseRecorder) { 31 // req := httptest.NewRequest(echo.GET, url, nil) 32 // rec := httptest.NewRecorder() 33 // ctx := e.NewContext(req, rec) 34 // return ctx, rec 35 // }