Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
ff1b8588
Commit
ff1b8588
authored
Nov 26, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#313
parent
54fb49ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
router_test.go
router_test.go
+31
-0
No files found.
router_test.go
View file @
ff1b8588
...
@@ -27,6 +27,25 @@ func (this *TestController) GetUrl() {
...
@@ -27,6 +27,25 @@ func (this *TestController) GetUrl() {
this
.
Ctx
.
Output
.
Body
([]
byte
(
this
.
UrlFor
(
".Myext"
)))
this
.
Ctx
.
Output
.
Body
([]
byte
(
this
.
UrlFor
(
".Myext"
)))
}
}
type
ResStatus
struct
{
Code
int
Msg
string
}
type
JsonController
struct
{
Controller
}
func
(
this
*
JsonController
)
Prepare
()
{
this
.
Data
[
"json"
]
=
"prepare"
this
.
ServeJson
(
true
)
}
func
(
this
*
JsonController
)
Get
()
{
this
.
Data
[
"Username"
]
=
"astaxie"
this
.
Ctx
.
Output
.
Body
([]
byte
(
"ok"
))
}
func
TestUrlFor
(
t
*
testing
.
T
)
{
func
TestUrlFor
(
t
*
testing
.
T
)
{
handler
:=
NewControllerRegistor
()
handler
:=
NewControllerRegistor
()
handler
.
Add
(
"/api/list"
,
&
TestController
{},
"*:List"
)
handler
.
Add
(
"/api/list"
,
&
TestController
{},
"*:List"
)
...
@@ -151,3 +170,15 @@ func TestStatic(t *testing.T) {
...
@@ -151,3 +170,15 @@ func TestStatic(t *testing.T) {
t
.
Errorf
(
"handler.Static failed to serve file"
)
t
.
Errorf
(
"handler.Static failed to serve file"
)
}
}
}
}
func
TestPrepare
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/json/list"
,
nil
)
w
:=
httptest
.
NewRecorder
()
handler
:=
NewControllerRegistor
()
handler
.
Add
(
"/json/list"
,
&
JsonController
{})
handler
.
ServeHTTP
(
w
,
r
)
if
w
.
Body
.
String
()
!=
`"prepare"`
{
t
.
Errorf
(
w
.
Body
.
String
()
+
"user define func can't run"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment