cloudflare-workers/exp/hono/middleware_test.go
2024-02-11 19:30:23 +09:00

33 lines
548 B
Go

package hono
import "testing"
func TestChainMiddlewares(t *testing.T) {
result := ""
middlewares := []Middleware{
func(c *Context, next func()) {
result += "1"
next()
result += "1"
},
func(c *Context, next func()) {
result += "2"
next()
result += "2"
},
func(c *Context, next func()) {
result += "3"
next()
result += "3"
},
}
m := ChainMiddlewares(middlewares...)
m(nil, func() {
result += "0"
})
const want = "1230321"
if result != want {
t.Errorf("result: got %q, want %q", result, want)
}
}