mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
1b3197a149
Signed-off-by: Vishal Rana <vr@labstack.com>
34 lines
818 B
Go
34 lines
818 B
Go
package middleware
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/labstack/echo"
|
|
"github.com/labstack/echo/test"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAddTrailingSlash(t *testing.T) {
|
|
e := echo.New()
|
|
rq := test.NewRequest(echo.GET, "/add-slash", nil)
|
|
rc := test.NewResponseRecorder()
|
|
c := echo.NewContext(rq, rc, e)
|
|
h := AddTrailingSlash()(echo.HandlerFunc(func(c echo.Context) error {
|
|
return nil
|
|
}))
|
|
h.Handle(c)
|
|
assert.Equal(t, "/add-slash/", rq.URL().Path())
|
|
}
|
|
|
|
func TestRemoveTrailingSlash(t *testing.T) {
|
|
e := echo.New()
|
|
rq := test.NewRequest(echo.GET, "/remove-slash/", nil)
|
|
rc := test.NewResponseRecorder()
|
|
c := echo.NewContext(rq, rc, e)
|
|
h := RemoveTrailingSlash()(echo.HandlerFunc(func(c echo.Context) error {
|
|
return nil
|
|
}))
|
|
h.Handle(c)
|
|
assert.Equal(t, "/remove-slash", rq.URL().Path())
|
|
}
|