add test for count with orderby and limit

This commit is contained in:
Lunny Xiao 2018-04-10 11:20:13 +08:00
parent 99ab88dbcf
commit 4021942b39
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 25 additions and 0 deletions

View File

@ -158,3 +158,28 @@ func TestSQLCount(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, 0, total) assert.EqualValues(t, 0, total)
} }
func TestCountWithOthers(t *testing.T) {
assert.NoError(t, prepareEngine())
type CountWithOthers struct {
Id int64
Name string
}
assertSync(t, new(CountWithOthers))
_, err := testEngine.Insert(&CountWithOthers{
Name: "orderby",
})
assert.NoError(t, err)
_, err = testEngine.Insert(&CountWithOthers{
Name: "limit",
})
assert.NoError(t, err)
total, err := testEngine.OrderBy("id desc").Limit(1).Count(new(CountWithOthers))
assert.NoError(t, err)
assert.EqualValues(t, 2, total)
}