mirror of
https://github.com/astaxie/beego.git
synced 2025-07-04 09:50:18 +00:00
orm: add inline struct test case
This commit is contained in:
@ -187,6 +187,7 @@ func TestSyncDb(t *testing.T) {
|
||||
RegisterModel(new(Group))
|
||||
RegisterModel(new(Permission))
|
||||
RegisterModel(new(GroupPermissions))
|
||||
RegisterModel(new(InLine))
|
||||
|
||||
err := RunSyncdb("default", true, Debug)
|
||||
throwFail(t, err)
|
||||
@ -206,6 +207,7 @@ func TestRegisterModels(t *testing.T) {
|
||||
RegisterModel(new(Group))
|
||||
RegisterModel(new(Permission))
|
||||
RegisterModel(new(GroupPermissions))
|
||||
RegisterModel(new(InLine))
|
||||
|
||||
BootStrap()
|
||||
|
||||
@ -1928,3 +1930,25 @@ func TestReadOrCreate(t *testing.T) {
|
||||
|
||||
dORM.Delete(u)
|
||||
}
|
||||
|
||||
func TestInLine(t *testing.T) {
|
||||
name := "inline"
|
||||
email := "hello@go.com"
|
||||
inline := NewInLine()
|
||||
inline.Name = name
|
||||
inline.Email = email
|
||||
|
||||
id, err := dORM.Insert(inline)
|
||||
throwFail(t, err)
|
||||
throwFail(t, AssertIs(id, 1))
|
||||
|
||||
il := NewInLine()
|
||||
il.Id = 1
|
||||
err = dORM.Read(il)
|
||||
throwFail(t, err)
|
||||
|
||||
throwFail(t, AssertIs(il.Name, name))
|
||||
throwFail(t, AssertIs(il.Email, email))
|
||||
throwFail(t, AssertIs(il.Created.In(DefaultTimeLoc), inline.Created.In(DefaultTimeLoc), testDate))
|
||||
throwFail(t, AssertIs(il.Updated.In(DefaultTimeLoc), inline.Updated.In(DefaultTimeLoc), testDateTime))
|
||||
}
|
||||
|
Reference in New Issue
Block a user