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
40700a85
Commit
40700a85
authored
Nov 25, 2015
by
JessonChan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/upstream/develop' into fargo
# Conflicts: # memzipfile.go
parents
9170b910
235b5850
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
controller_test.go
controller_test.go
+22
-13
migration.go
migration/migration.go
+2
-2
No files found.
controller_test.go
View file @
40700a85
...
...
@@ -17,42 +17,48 @@ package beego
import
(
"fmt"
"github.com/astaxie/beego/context"
"testing"
)
func
ExampleGetInt
(
)
{
func
TestGetInt
(
t
*
testing
.
T
)
{
i
:=
&
context
.
BeegoInput
{
Params
:
map
[
string
]
string
{
"age"
:
"40"
}}
ctx
:=
&
context
.
Context
{
Input
:
i
}
ctrlr
:=
Controller
{
Ctx
:
ctx
}
val
,
_
:=
ctrlr
.
GetInt
(
"age"
)
fmt
.
Printf
(
"%T"
,
val
)
//Output: int
if
(
val
!=
40
)
{
t
.
Errorf
(
"TestGetInt expect 40,get %T,%v"
,
val
,
val
)
}
}
func
ExampleGetInt8
(
)
{
func
TestGetInt8
(
t
*
testing
.
T
)
{
i
:=
&
context
.
BeegoInput
{
Params
:
map
[
string
]
string
{
"age"
:
"40"
}}
ctx
:=
&
context
.
Context
{
Input
:
i
}
ctrlr
:=
Controller
{
Ctx
:
ctx
}
val
,
_
:=
ctrlr
.
GetInt8
(
"age"
)
fmt
.
Printf
(
"%T"
,
val
)
if
val
!=
40
{
t
.
Errorf
(
"TestGetInt8 expect 40,get %T,%v"
,
val
,
val
)
}
//Output: int8
}
func
ExampleGetInt16
(
)
{
func
TestGetInt16
(
t
*
testing
.
T
)
{
i
:=
&
context
.
BeegoInput
{
Params
:
map
[
string
]
string
{
"age"
:
"40"
}}
ctx
:=
&
context
.
Context
{
Input
:
i
}
ctrlr
:=
Controller
{
Ctx
:
ctx
}
val
,
_
:=
ctrlr
.
GetInt16
(
"age"
)
fmt
.
Printf
(
"%T"
,
val
)
//Output: int16
if
val
!=
40
{
t
.
Errorf
(
"TestGetInt16 expect 40,get %T,%v"
,
val
,
val
)
}
}
func
ExampleGetInt32
(
)
{
func
TestGetInt32
(
t
*
testing
.
T
)
{
i
:=
&
context
.
BeegoInput
{
Params
:
map
[
string
]
string
{
"age"
:
"40"
}}
ctx
:=
&
context
.
Context
{
Input
:
i
}
...
...
@@ -60,16 +66,19 @@ func ExampleGetInt32() {
val
,
_
:=
ctrlr
.
GetInt32
(
"age"
)
fmt
.
Printf
(
"%T"
,
val
)
//Output: int32
if
val
!=
40
{
t
.
Errorf
(
"TestGetInt32 expect 40,get %T,%v"
,
val
,
val
)
}
}
func
ExampleGetInt64
(
)
{
func
TestGetInt64
(
t
*
testing
.
T
)
{
i
:=
&
context
.
BeegoInput
{
Params
:
map
[
string
]
string
{
"age"
:
"40"
}}
ctx
:=
&
context
.
Context
{
Input
:
i
}
ctrlr
:=
Controller
{
Ctx
:
ctx
}
val
,
_
:=
ctrlr
.
GetInt64
(
"age"
)
fmt
.
Printf
(
"%T"
,
val
)
//Output: int64
if
val
!=
40
{
t
.
Errorf
(
"TestGeetInt64 expect 40,get %T,%v"
,
val
,
val
)
}
}
migration/migration.go
View file @
40700a85
...
...
@@ -104,7 +104,7 @@ func (m *Migration) addOrUpdateRecord(name, status string) error {
o
:=
orm
.
NewOrm
()
if
status
==
"down"
{
status
=
"rollback"
p
,
err
:=
o
.
Raw
(
"update migrations set
`status` = ?, `rollback_statements` = ?, `created_at`
= ? where name = ?"
)
.
Prepare
()
p
,
err
:=
o
.
Raw
(
"update migrations set
status = ?, rollback_statements = ?, created_at
= ? where name = ?"
)
.
Prepare
()
if
err
!=
nil
{
return
nil
}
...
...
@@ -112,7 +112,7 @@ func (m *Migration) addOrUpdateRecord(name, status string) error {
return
err
}
status
=
"update"
p
,
err
:=
o
.
Raw
(
"insert into migrations(
`name`, `created_at`, `statements`, `status`
) values(?,?,?,?)"
)
.
Prepare
()
p
,
err
:=
o
.
Raw
(
"insert into migrations(
name, created_at, statements, status
) values(?,?,?,?)"
)
.
Prepare
()
if
err
!=
nil
{
return
err
}
...
...
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