05e5baaa by astaxie

beego:add post test case

1 parent 54b92e95
...@@ -15,6 +15,10 @@ func (this *TestController) Get() { ...@@ -15,6 +15,10 @@ func (this *TestController) Get() {
15 this.Ctx.Output.Body([]byte("ok")) 15 this.Ctx.Output.Body([]byte("ok"))
16 } 16 }
17 17
18 func (this *TestController) Post() {
19 this.Ctx.Output.Body([]byte(this.Ctx.Input.Query(":name")))
20 }
21
18 func (this *TestController) List() { 22 func (this *TestController) List() {
19 this.Ctx.Output.Body([]byte("i am list")) 23 this.Ctx.Output.Body([]byte("i am list"))
20 } 24 }
...@@ -81,6 +85,18 @@ func TestUserFunc(t *testing.T) { ...@@ -81,6 +85,18 @@ func TestUserFunc(t *testing.T) {
81 } 85 }
82 } 86 }
83 87
88 func TestPostFunc(t *testing.T) {
89 r, _ := http.NewRequest("POST", "/astaxie", nil)
90 w := httptest.NewRecorder()
91
92 handler := NewControllerRegistor()
93 handler.Add("/:name", &TestController{})
94 handler.ServeHTTP(w, r)
95 if w.Body.String() != "astaxie" {
96 t.Errorf("post func should astaxie")
97 }
98 }
99
84 func TestAutoFunc(t *testing.T) { 100 func TestAutoFunc(t *testing.T) {
85 r, _ := http.NewRequest("GET", "/test/list", nil) 101 r, _ := http.NewRequest("GET", "/test/list", nil)
86 w := httptest.NewRecorder() 102 w := httptest.NewRecorder()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!