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
84ae930c
Commit
84ae930c
authored
Mar 18, 2016
by
miraclesu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
orm: Add test case for integer pk
parent
a3d4218d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
models_test.go
orm/models_test.go
+5
-0
orm_test.go
orm/orm_test.go
+22
-0
No files found.
orm/models_test.go
View file @
84ae930c
...
...
@@ -387,6 +387,11 @@ func NewInLineOneToOne() *InLineOneToOne {
return
new
(
InLineOneToOne
)
}
type
IntegerPk
struct
{
Id
int64
`orm:"pk"`
Value
string
}
var
DBARGS
=
struct
{
Driver
string
Source
string
...
...
orm/orm_test.go
View file @
84ae930c
...
...
@@ -19,6 +19,7 @@ import (
"database/sql"
"fmt"
"io/ioutil"
"math"
"os"
"path/filepath"
"reflect"
...
...
@@ -189,6 +190,7 @@ func TestSyncDb(t *testing.T) {
RegisterModel
(
new
(
GroupPermissions
))
RegisterModel
(
new
(
InLine
))
RegisterModel
(
new
(
InLineOneToOne
))
RegisterModel
(
new
(
IntegerPk
))
err
:=
RunSyncdb
(
"default"
,
true
,
Debug
)
throwFail
(
t
,
err
)
...
...
@@ -210,6 +212,7 @@ func TestRegisterModels(t *testing.T) {
RegisterModel
(
new
(
GroupPermissions
))
RegisterModel
(
new
(
InLine
))
RegisterModel
(
new
(
InLineOneToOne
))
RegisterModel
(
new
(
IntegerPk
))
BootStrap
()
...
...
@@ -1991,3 +1994,22 @@ func TestInLineOneToOne(t *testing.T) {
throwFail
(
t
,
AssertIs
(
rinline
.
Name
,
name
))
throwFail
(
t
,
AssertIs
(
rinline
.
Email
,
email
))
}
func
TestIntegerPk
(
t
*
testing
.
T
)
{
its
:=
[]
IntegerPk
{
{
Id
:
math
.
MinInt64
,
Value
:
"-"
},
{
Id
:
0
,
Value
:
"0"
},
{
Id
:
math
.
MaxInt64
,
Value
:
"+"
},
}
num
,
err
:=
dORM
.
InsertMulti
(
len
(
its
),
its
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
num
,
len
(
its
)))
for
_
,
intPk
:=
range
its
{
out
:=
IntegerPk
{
Id
:
intPk
.
Id
}
err
=
dORM
.
Read
(
&
out
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
out
.
Value
,
intPk
.
Value
))
}
}
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