mirror of
https://github.com/astaxie/beego.git
synced 2025-07-01 04:30:19 +00:00
fix #201
This commit is contained in:
@ -21,6 +21,10 @@ func (this *TestController) List() {
|
||||
this.Ctx.Output.Body([]byte("i am list"))
|
||||
}
|
||||
|
||||
func (this *TestController) Myext() {
|
||||
this.Ctx.Output.Body([]byte(this.Ctx.Input.Params(":ext")))
|
||||
}
|
||||
|
||||
func TestUserFunc(t *testing.T) {
|
||||
r, _ := http.NewRequest("GET", "/api/list", nil)
|
||||
w := httptest.NewRecorder()
|
||||
@ -45,6 +49,18 @@ func TestAutoFunc(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoExtFunc(t *testing.T) {
|
||||
r, _ := http.NewRequest("GET", "/test/myext.json", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handler := NewControllerRegistor()
|
||||
handler.AddAuto(&TestController{})
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Body.String() != "json" {
|
||||
t.Errorf("user define func can't run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteOk(t *testing.T) {
|
||||
|
||||
r, _ := http.NewRequest("GET", "/person/anderson/thomas?learn=kungfu", nil)
|
||||
|
Reference in New Issue
Block a user