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
e4066d82
Commit
e4066d82
authored
Mar 14, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1790 from miraclesu/feature/orm_inline_struct
orm: inline struct relate test case
parents
cc2b5f5b
dcfcb278
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
models_test.go
orm/models_test.go
+12
-0
orm_test.go
orm/orm_test.go
+39
-0
No files found.
orm/models_test.go
View file @
e4066d82
...
...
@@ -375,6 +375,18 @@ func NewInLine() *InLine {
return
new
(
InLine
)
}
type
InLineOneToOne
struct
{
// Common Fields
ModelBase
Note
string
InLine
*
InLine
`orm:"rel(fk);column(inline)"`
}
func
NewInLineOneToOne
()
*
InLineOneToOne
{
return
new
(
InLineOneToOne
)
}
var
DBARGS
=
struct
{
Driver
string
Source
string
...
...
orm/orm_test.go
View file @
e4066d82
...
...
@@ -188,6 +188,7 @@ func TestSyncDb(t *testing.T) {
RegisterModel
(
new
(
Permission
))
RegisterModel
(
new
(
GroupPermissions
))
RegisterModel
(
new
(
InLine
))
RegisterModel
(
new
(
InLineOneToOne
))
err
:=
RunSyncdb
(
"default"
,
true
,
Debug
)
throwFail
(
t
,
err
)
...
...
@@ -208,6 +209,7 @@ func TestRegisterModels(t *testing.T) {
RegisterModel
(
new
(
Permission
))
RegisterModel
(
new
(
GroupPermissions
))
RegisterModel
(
new
(
InLine
))
RegisterModel
(
new
(
InLineOneToOne
))
BootStrap
()
...
...
@@ -1952,3 +1954,40 @@ func TestInLine(t *testing.T) {
throwFail
(
t
,
AssertIs
(
il
.
Created
.
In
(
DefaultTimeLoc
),
inline
.
Created
.
In
(
DefaultTimeLoc
),
testDate
))
throwFail
(
t
,
AssertIs
(
il
.
Updated
.
In
(
DefaultTimeLoc
),
inline
.
Updated
.
In
(
DefaultTimeLoc
),
testDateTime
))
}
func
TestInLineOneToOne
(
t
*
testing
.
T
)
{
name
:=
"121"
email
:=
"121@go.com"
inline
:=
NewInLine
()
inline
.
Name
=
name
inline
.
Email
=
email
id
,
err
:=
dORM
.
Insert
(
inline
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
id
,
2
))
note
:=
"one2one"
il121
:=
NewInLineOneToOne
()
il121
.
Note
=
note
il121
.
InLine
=
inline
_
,
err
=
dORM
.
Insert
(
il121
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
il121
.
ID
,
1
))
il
:=
NewInLineOneToOne
()
err
=
dORM
.
QueryTable
(
il
)
.
Filter
(
"Id"
,
1
)
.
RelatedSel
()
.
One
(
il
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
il
.
Note
,
note
))
throwFail
(
t
,
AssertIs
(
il
.
InLine
.
ID
,
id
))
throwFail
(
t
,
AssertIs
(
il
.
InLine
.
Name
,
name
))
throwFail
(
t
,
AssertIs
(
il
.
InLine
.
Email
,
email
))
rinline
:=
NewInLine
()
err
=
dORM
.
QueryTable
(
rinline
)
.
Filter
(
"InLineOneToOne__Id"
,
1
)
.
One
(
rinline
)
throwFail
(
t
,
err
)
throwFail
(
t
,
AssertIs
(
rinline
.
ID
,
id
))
throwFail
(
t
,
AssertIs
(
rinline
.
Name
,
name
))
throwFail
(
t
,
AssertIs
(
rinline
.
Email
,
email
))
}
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