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
1ea449aa
Commit
1ea449aa
authored
Apr 10, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego:add post test case
parent
b212ec8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
router_test.go
router_test.go
+16
-0
No files found.
router_test.go
View file @
1ea449aa
...
...
@@ -15,6 +15,10 @@ func (this *TestController) Get() {
this
.
Ctx
.
Output
.
Body
([]
byte
(
"ok"
))
}
func
(
this
*
TestController
)
Post
()
{
this
.
Ctx
.
Output
.
Body
([]
byte
(
this
.
Ctx
.
Input
.
Query
(
":name"
)))
}
func
(
this
*
TestController
)
List
()
{
this
.
Ctx
.
Output
.
Body
([]
byte
(
"i am list"
))
}
...
...
@@ -81,6 +85,18 @@ func TestUserFunc(t *testing.T) {
}
}
func
TestPostFunc
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"POST"
,
"/astaxie"
,
nil
)
w
:=
httptest
.
NewRecorder
()
handler
:=
NewControllerRegistor
()
handler
.
Add
(
"/:name"
,
&
TestController
{})
handler
.
ServeHTTP
(
w
,
r
)
if
w
.
Body
.
String
()
!=
"astaxie"
{
t
.
Errorf
(
"post func should astaxie"
)
}
}
func
TestAutoFunc
(
t
*
testing
.
T
)
{
r
,
_
:=
http
.
NewRequest
(
"GET"
,
"/test/list"
,
nil
)
w
:=
httptest
.
NewRecorder
()
...
...
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