Skip to content

Commit

Permalink
add UT case for package gdb
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Mar 31, 2022
1 parent 66803fd commit 52d8371
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions database/gdb/gdb_z_mysql_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/guid"
"github.com/gogf/gf/v2/util/gutil"
)

Expand Down Expand Up @@ -688,6 +689,18 @@ func Test_Model_Count(t *testing.T) {
t.AssertNil(err)
t.Assert(count, TableSize)
})
// Count with cache, check internal ctx data feature.
gtest.C(t, func(t *gtest.T) {
for i := 0; i < 10; i++ {
count, err := db.Model(table).Cache(gdb.CacheOption{
Duration: time.Second * 10,
Name: guid.S(),
Force: false,
}).Count()
t.AssertNil(err)
t.Assert(count, TableSize)
}
})
gtest.C(t, func(t *gtest.T) {
count, err := db.Model(table).FieldsEx("id").Where("id>8").Count()
t.AssertNil(err)
Expand Down

0 comments on commit 52d8371

Please sign in to comment.