MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / newUserExampleDao

Function newUserExampleDao

internal/dao/userExample_test.go:18–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16)
17
18func newUserExampleDao() *gotest.Dao {
19 testData := &model.UserExample{}
20 testData.ID = 1
21 // you can set the other fields of testData here, such as:
22 //testData.CreatedAt = time.Now()
23 //testData.UpdatedAt = testData.CreatedAt
24
25 // init mock cache
26 //c := gotest.NewCache(map[string]interface{}{"no cache": testData}) // to test mysql, disable caching
27 c := gotest.NewCache(map[string]interface{}{utils.Uint64ToStr(testData.ID): testData})
28 c.ICache = cache.NewUserExampleCache(&database.CacheType{
29 CType: "redis",
30 Rdb: c.RedisClient,
31 })
32
33 // init mock dao
34 d := gotest.NewDao(c, testData)
35 d.IDao = NewUserExampleDao(d.DB, c.ICache.(cache.UserExampleCache))
36
37 return d
38}
39
40func Test_userExampleDao_Create(t *testing.T) {
41 d := newUserExampleDao()

Calls 5

NewCacheFunction · 0.92
Uint64ToStrFunction · 0.92
NewUserExampleCacheFunction · 0.92
NewDaoFunction · 0.92
NewUserExampleDaoFunction · 0.85

Tested by

no test coverage detected