Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
05e5baaa
authored
2014-04-10 22:33:32 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
beego:add post test case
1 parent
54b92e95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
router_test.go
router_test.go
View file @
05e5baa
...
...
@@ -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
Styling with
Markdown
is supported
Attach a file
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 post a comment