add UT for issue 3928
This commit is contained in:
parent
e597b05c93
commit
6e4398f7ec
@ -26,6 +26,14 @@ import (
|
|||||||
"github.com/beego/beego/v2/server/web/context"
|
"github.com/beego/beego/v2/server/web/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type PrefixTestController struct {
|
||||||
|
Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ptc *PrefixTestController) PrefixList() {
|
||||||
|
ptc.Ctx.Output.Body([]byte("i am list in prefix test"))
|
||||||
|
}
|
||||||
|
|
||||||
type TestController struct {
|
type TestController struct {
|
||||||
Controller
|
Controller
|
||||||
}
|
}
|
||||||
@ -87,6 +95,20 @@ func (jc *JSONController) Get() {
|
|||||||
jc.Ctx.Output.Body([]byte("ok"))
|
jc.Ctx.Output.Body([]byte("ok"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrefixUrlFor(t *testing.T){
|
||||||
|
handler := NewControllerRegister()
|
||||||
|
handler.Add("/my/prefix/list", &PrefixTestController{}, "get:PrefixList")
|
||||||
|
|
||||||
|
if a := handler.URLFor(`PrefixTestController.PrefixList`); a != `/my/prefix/list` {
|
||||||
|
logs.Info(a)
|
||||||
|
t.Errorf("PrefixTestController.PrefixList must equal to /my/prefix/list")
|
||||||
|
}
|
||||||
|
if a := handler.URLFor(`TestController.PrefixList`); a != `` {
|
||||||
|
logs.Info(a)
|
||||||
|
t.Errorf("TestController.PrefixList must equal to empty string")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUrlFor(t *testing.T) {
|
func TestUrlFor(t *testing.T) {
|
||||||
handler := NewControllerRegister()
|
handler := NewControllerRegister()
|
||||||
handler.Add("/api/list", &TestController{}, "*:List")
|
handler.Add("/api/list", &TestController{}, "*:List")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user