2015-05-13 23:07:03 -07:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/labstack/echo"
|
2015-05-30 10:54:55 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
2015-05-13 23:07:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStripTrailingSlash(t *testing.T) {
|
|
|
|
req, _ := http.NewRequest(echo.GET, "/users/", nil)
|
2015-05-30 10:54:55 -07:00
|
|
|
rec := httptest.NewRecorder()
|
|
|
|
c := echo.NewContext(req, echo.NewResponse(rec), echo.New())
|
2015-05-13 23:07:03 -07:00
|
|
|
StripTrailingSlash()(c)
|
2015-05-30 10:54:55 -07:00
|
|
|
assert.Equal(t, "/users", c.Request().URL.Path)
|
2015-05-13 23:07:03 -07:00
|
|
|
}
|