1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-01 22:51:17 +02:00

Bumped to v1.3

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-12-01 11:22:45 -08:00
parent f54cdd86d0
commit 9650c39055
13 changed files with 86 additions and 68 deletions

View File

@@ -8,7 +8,6 @@ import (
"testing"
"github.com/labstack/echo"
"github.com/labstack/gommon/log"
"github.com/stretchr/testify/assert"
)
@@ -17,7 +16,7 @@ func TestLogger(t *testing.T) {
e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), e)
c := echo.NewContext(req, echo.NewResponse(rec, e), e)
// Status 2xx
h := func(c *echo.Context) error {
@@ -27,7 +26,7 @@ func TestLogger(t *testing.T) {
// Status 3xx
rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e)
c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error {
return c.String(http.StatusTemporaryRedirect, "test")
}
@@ -35,7 +34,7 @@ func TestLogger(t *testing.T) {
// Status 4xx
rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e)
c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error {
return c.String(http.StatusNotFound, "test")
}
@@ -44,7 +43,7 @@ func TestLogger(t *testing.T) {
// Status 5xx with empty path
req, _ = http.NewRequest(echo.GET, "", nil)
rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e)
c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error {
return errors.New("error")
}
@@ -52,14 +51,13 @@ func TestLogger(t *testing.T) {
}
func TestLoggerIPAddress(t *testing.T) {
buf := &bytes.Buffer{}
log.SetOutput(buf)
ip := "127.0.0.1"
e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), e)
c := echo.NewContext(req, echo.NewResponse(rec, e), e)
buf := new(bytes.Buffer)
e.Logger().SetOutput(buf)
ip := "127.0.0.1"
h := func(c *echo.Context) error {
return c.String(http.StatusOK, "test")
}