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
11ef5929
Commit
11ef5929
authored
Sep 02, 2016
by
Zaaksam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update TestParseForm
parent
7c2e5638
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
9 deletions
+37
-9
templatefunc_test.go
templatefunc_test.go
+37
-9
No files found.
templatefunc_test.go
View file @
11ef5929
...
...
@@ -110,6 +110,17 @@ func TestHtmlunquote(t *testing.T) {
}
func
TestParseForm
(
t
*
testing
.
T
)
{
type
ExtendInfo
struct
{
Hobby
string
`form:"hobby"`
Memo
string
}
type
OtherInfo
struct
{
Organization
string
`form:"organization"`
Title
string
`form:"title"`
ExtendInfo
}
type
user
struct
{
ID
int
`form:"-"`
tag
string
`form:"tag"`
...
...
@@ -119,19 +130,24 @@ func TestParseForm(t *testing.T) {
Intro
string
`form:",textarea"`
StrBool
bool
`form:"strbool"`
Date
time
.
Time
`form:"date,2006-01-02"`
OtherInfo
}
u
:=
user
{}
form
:=
url
.
Values
{
"ID"
:
[]
string
{
"1"
},
"-"
:
[]
string
{
"1"
},
"tag"
:
[]
string
{
"no"
},
"username"
:
[]
string
{
"test"
},
"age"
:
[]
string
{
"40"
},
"Email"
:
[]
string
{
"test@gmail.com"
},
"Intro"
:
[]
string
{
"I am an engineer!"
},
"strbool"
:
[]
string
{
"yes"
},
"date"
:
[]
string
{
"2014-11-12"
},
"ID"
:
[]
string
{
"1"
},
"-"
:
[]
string
{
"1"
},
"tag"
:
[]
string
{
"no"
},
"username"
:
[]
string
{
"test"
},
"age"
:
[]
string
{
"40"
},
"Email"
:
[]
string
{
"test@gmail.com"
},
"Intro"
:
[]
string
{
"I am an engineer!"
},
"strbool"
:
[]
string
{
"yes"
},
"date"
:
[]
string
{
"2014-11-12"
},
"organization"
:
[]
string
{
"beego"
},
"title"
:
[]
string
{
"CXO"
},
"hobby"
:
[]
string
{
"Basketball"
},
"memo"
:
[]
string
{
"nothing"
},
}
if
err
:=
ParseForm
(
form
,
u
);
err
==
nil
{
t
.
Fatal
(
"nothing will be changed"
)
...
...
@@ -164,6 +180,18 @@ func TestParseForm(t *testing.T) {
if
y
!=
2014
||
m
.
String
()
!=
"November"
||
d
!=
12
{
t
.
Errorf
(
"Date should equal `2014-11-12`, but got `%v`"
,
u
.
Date
.
String
())
}
if
u
.
Organization
!=
"beego"
{
t
.
Errorf
(
"Organization should equal `beego`, but got `%v`"
,
u
.
Organization
)
}
if
u
.
Title
!=
"CXO"
{
t
.
Errorf
(
"Title should equal `CXO`, but got `%v`"
,
u
.
Title
)
}
if
u
.
Hobby
!=
"Basketball"
{
t
.
Errorf
(
"Hobby should equal `Basketball`, but got `%v`"
,
u
.
Hobby
)
}
if
len
(
u
.
Memo
)
!=
0
{
t
.
Errorf
(
"Memo's length should equal 0 but got %v"
,
len
(
u
.
Memo
))
}
}
func
TestRenderForm
(
t
*
testing
.
T
)
{
...
...
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