27 Star 81 Fork 11

lunny/tango

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
handler_test.go 703 Bytes
一键复制 编辑 原始数据 按行查看 历史
lunny 提交于 2018-04-12 22:57 +08:00 . bug fixed for second group
package tango
import (
"bytes"
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
func TestGroupGroup(t *testing.T) {
var a int
tg := Classic()
tg.Group("/api", func(api *Group) {
api.Group("/v1", func(v1 *Group) {
v1.Use(HandlerFunc(func(ctx *Context) {
a = 1
ctx.Next()
}))
v1.Get("/", func(ctx *Context) {
fmt.Println("context")
})
})
})
buff := bytes.NewBufferString("")
recorder := httptest.NewRecorder()
recorder.Body = buff
req, err := http.NewRequest("GET", "http://localhost:8000/api/v1", nil)
if err != nil {
t.Error(err)
}
tg.ServeHTTP(recorder, req)
expect(t, recorder.Code, http.StatusOK)
expect(t, buff.String(), "")
expect(t, 1, a)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lunny/tango.git
git@gitee.com:lunny/tango.git
lunny
tango
tango
master

搜索帮助