Skip to content

Commit

Permalink
Cache limit test (go-xorm#917)
Browse files Browse the repository at this point in the history
* add test for cache with limit

* change the version
  • Loading branch information
lunny authored Apr 29, 2018
1 parent e3550c7 commit 44623fc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions session_find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"testing"
"time"

"github.com/go-xorm/core"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -729,3 +730,40 @@ func TestFindExtends3(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, 2, len(results))
}

func TestFindCacheLimit(t *testing.T) {
type InviteCode struct {
ID int64 `xorm:"pk autoincr 'id'"`
Code string `xorm:"unique"`
Created time.Time `xorm:"created"`
}

assert.NoError(t, prepareEngine())
assertSync(t, new(InviteCode))

cnt, err := testEngine.Insert(&InviteCode{
Code: "123456",
})
assert.NoError(t, err)
assert.EqualValues(t, 1, cnt)

cnt, err = testEngine.Insert(&InviteCode{
Code: "234567",
})
assert.NoError(t, err)
assert.EqualValues(t, 1, cnt)

for i := 0; i < 8; i++ {
var beans []InviteCode
err = testEngine.Limit(1, 0).Find(&beans)
assert.NoError(t, err)
assert.EqualValues(t, 1, len(beans))
}

for i := 0; i < 8; i++ {
var beans2 []*InviteCode
err = testEngine.Limit(1, 0).Find(&beans2)
assert.NoError(t, err)
assert.EqualValues(t, 1, len(beans2))
}
}
2 changes: 1 addition & 1 deletion xorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

const (
// Version show the xorm's version
Version string = "0.6.6.0413"
Version string = "0.6.6.0429"
)

func regDrvsNDialects() bool {
Expand Down

0 comments on commit 44623fc

Please sign in to comment.