mirror of
https://github.com/astaxie/beego.git
synced 2025-07-01 03:40:19 +00:00
beego: update licence& fix #669
This commit is contained in:
@ -1,13 +1,12 @@
|
||||
// Beego (http://beego.me/)
|
||||
|
||||
//
|
||||
// @description beego is an open-source, high-performance web framework for the Go programming language.
|
||||
|
||||
//
|
||||
// @link http://github.com/astaxie/beego for the canonical source repository
|
||||
|
||||
//
|
||||
// @license http://github.com/astaxie/beego/blob/master/LICENSE
|
||||
|
||||
//
|
||||
// @authors astaxie
|
||||
|
||||
package beego
|
||||
|
||||
import (
|
||||
@ -95,10 +94,10 @@ func TestUrlFor(t *testing.T) {
|
||||
func TestUrlFor3(t *testing.T) {
|
||||
handler := NewControllerRegister()
|
||||
handler.AddAuto(&TestController{})
|
||||
if a := handler.UrlFor("TestController.Myext"); a != "/test/myext" {
|
||||
if a := handler.UrlFor("TestController.Myext"); a != "/test/myext" && a != "/Test/Myext" {
|
||||
t.Errorf("TestController.Myext must equal to /test/myext, but get " + a)
|
||||
}
|
||||
if a := handler.UrlFor("TestController.GetUrl"); a != "/test/geturl" {
|
||||
if a := handler.UrlFor("TestController.GetUrl"); a != "/test/geturl" && a != "/Test/GetUrl" {
|
||||
t.Errorf("TestController.GetUrl must equal to /test/geturl, but get " + a)
|
||||
}
|
||||
}
|
||||
@ -106,8 +105,14 @@ func TestUrlFor3(t *testing.T) {
|
||||
func TestUrlFor2(t *testing.T) {
|
||||
handler := NewControllerRegister()
|
||||
handler.Add("/v1/:v/cms_:id(.+)_:page(.+).html", &TestController{}, "*:List")
|
||||
handler.Add("/v1/:username/edit", &TestController{}, "get:GetUrl")
|
||||
handler.Add("/v1/:v(.+)_cms/ttt_:id(.+)_:page(.+).html", &TestController{}, "*:Param")
|
||||
handler.Add("/:year:int/:month:int/:title/:entid", &TestController{})
|
||||
if handler.UrlFor("TestController.GetUrl", ":username", "astaxie") != "/v1/astaxie/edit" {
|
||||
Info(handler.UrlFor("TestController.GetUrl"))
|
||||
t.Errorf("TestController.List must equal to /v1/astaxie/edit")
|
||||
}
|
||||
|
||||
if handler.UrlFor("TestController.List", ":v", "za", ":id", "12", ":page", "123") !=
|
||||
"/v1/za/cms_12_123.html" {
|
||||
Info(handler.UrlFor("TestController.List"))
|
||||
@ -162,6 +167,18 @@ func TestAutoFunc(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoFunc2(t *testing.T) {
|
||||
r, _ := http.NewRequest("GET", "/Test/List", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
handler := NewControllerRegister()
|
||||
handler.AddAuto(&TestController{})
|
||||
handler.ServeHTTP(w, r)
|
||||
if w.Body.String() != "i am list" {
|
||||
t.Errorf("user define func can't run")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoFuncParams(t *testing.T) {
|
||||
r, _ := http.NewRequest("GET", "/test/params/2009/11/12", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
Reference in New Issue
Block a user