1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00
echo/group_test.go

55 lines
1.3 KiB
Go
Raw Normal View History

package echo
import (
"github.com/stretchr/testify/assert"
"testing"
)
2016-06-07 01:54:24 +02:00
// TODO: Fix me
func TestGroup(t *testing.T) {
g := New().Group("/group")
h := func(Context) error { return nil }
g.CONNECT("/", h)
2016-06-07 01:54:24 +02:00
g.Connect("/", h)
g.DELETE("/", h)
2016-06-07 01:54:24 +02:00
g.Delete("/", h)
g.GET("/", h)
2016-06-07 01:54:24 +02:00
g.Get("/", h)
g.HEAD("/", h)
2016-06-07 01:54:24 +02:00
g.Head("/", h)
g.OPTIONS("/", h)
2016-06-07 01:54:24 +02:00
g.Options("/", h)
g.PATCH("/", h)
2016-06-07 01:54:24 +02:00
g.Patch("/", h)
g.POST("/", h)
2016-06-07 01:54:24 +02:00
g.Post("/", h)
g.PUT("/", h)
2016-06-07 01:54:24 +02:00
g.Put("/", h)
g.TRACE("/", h)
2016-06-07 01:54:24 +02:00
g.Trace("/", h)
g.Any("/", h)
g.Match([]string{GET, POST}, "/", h)
g.Static("/static", "/tmp")
g.File("/walle", "_fixture/images//walle.png")
}
func TestGroupRouteMiddleware(t *testing.T) {
// Ensure middleware slices are not re-used
e := New()
g := e.Group("/group")
h := func(Context) error { return nil }
m1 := WrapMiddleware(func(c Context) error { return nil })
m2 := WrapMiddleware(func(c Context) error { return nil })
m3 := WrapMiddleware(func(c Context) error { return nil })
m4 := WrapMiddleware(func(c Context) error { return c.NoContent(404) })
m5 := WrapMiddleware(func(c Context) error { return c.NoContent(405) })
g.Use(m1, m2, m3)
g.GET("/404", h, m4)
g.GET("/405", h, m5)
c, _ := request(GET, "/group/404", e)
assert.Equal(t, 404, c)
c, _ = request(GET, "/group/405", e)
assert.Equal(t, 405, c)
}