提交 05e5baaa 编写于 作者: A astaxie

beego:add post test case

上级 54b92e95
......@@ -15,6 +15,10 @@ func (this *TestController) Get() {
this.Ctx.Output.Body([]byte("ok"))
}
func (this *TestController) Post() {
this.Ctx.Output.Body([]byte(this.Ctx.Input.Query(":name")))
}
func (this *TestController) List() {
this.Ctx.Output.Body([]byte("i am list"))
}
......@@ -81,6 +85,18 @@ func TestUserFunc(t *testing.T) {
}
}
func TestPostFunc(t *testing.T) {
r, _ := http.NewRequest("POST", "/astaxie", nil)
w := httptest.NewRecorder()
handler := NewControllerRegistor()
handler.Add("/:name", &TestController{})
handler.ServeHTTP(w, r)
if w.Body.String() != "astaxie" {
t.Errorf("post func should astaxie")
}
}
func TestAutoFunc(t *testing.T) {
r, _ := http.NewRequest("GET", "/test/list", nil)
w := httptest.NewRecorder()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册