mirror of
https://github.com/astaxie/beego.git
synced 2024-11-30 00:01:28 +00:00
update orm_test
This commit is contained in:
parent
f471ee9025
commit
4e10100575
@ -2187,81 +2187,75 @@ func TestInsertOrUpdate(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
//test1
|
//test1
|
||||||
test1:
|
|
||||||
_, err := dORM.InsertOrUpdate(&user1, "user_name")
|
_, err := dORM.InsertOrUpdate(&user1, "user_name")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
goto test2
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs(user1.Status, test.Status))
|
throwFailNow(t, AssertIs(user1.Status, test.Status))
|
||||||
}
|
}
|
||||||
//test2
|
//test2
|
||||||
test2:
|
|
||||||
_, err = dORM.InsertOrUpdate(&user2, "user_name")
|
_, err = dORM.InsertOrUpdate(&user2, "user_name")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
goto test3
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs(user2.Status, test.Status))
|
throwFailNow(t, AssertIs(user2.Status, test.Status))
|
||||||
throwFailNow(t, AssertIs(user2.Password, strings.TrimSpace(test.Password)))
|
throwFailNow(t, AssertIs(user2.Password, strings.TrimSpace(test.Password)))
|
||||||
}
|
}
|
||||||
//test3 +
|
//test3 +
|
||||||
test3:
|
|
||||||
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status+1")
|
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status+1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
goto test4
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs(user2.Status+1, test.Status))
|
throwFailNow(t, AssertIs(user2.Status+1, test.Status))
|
||||||
}
|
}
|
||||||
//test4 -
|
//test4 -
|
||||||
test4:
|
|
||||||
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status-1")
|
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status-1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
goto test5
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs((user2.Status+1)-1, test.Status))
|
throwFailNow(t, AssertIs((user2.Status+1)-1, test.Status))
|
||||||
}
|
}
|
||||||
//test5 *
|
//test5 *
|
||||||
test5:
|
|
||||||
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status*3")
|
_, err = dORM.InsertOrUpdate(&user2, "user_name", "status=status*3")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
goto test6
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs(((user2.Status+1)-1)*3, test.Status))
|
throwFailNow(t, AssertIs(((user2.Status+1)-1)*3, test.Status))
|
||||||
}
|
}
|
||||||
//test6 /
|
//test6 /
|
||||||
test6:
|
|
||||||
_, err = dORM.InsertOrUpdate(&user2, "user_name", "Status=Status/3")
|
_, err = dORM.InsertOrUpdate(&user2, "user_name", "Status=Status/3")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
if err.Error() == "postgres version must 9.5 or higher" || err.Error() == "`sqlite3` nonsupport InsertOrUpdate in beego" {
|
||||||
return
|
} else {
|
||||||
|
throwFailNow(t, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throwFailNow(t, err)
|
|
||||||
dORM.Read(&test, "user_name")
|
dORM.Read(&test, "user_name")
|
||||||
throwFailNow(t, AssertIs((((user2.Status+1)-1)*3)/3, test.Status))
|
throwFailNow(t, AssertIs((((user2.Status+1)-1)*3)/3, test.Status))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user