()
| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 40 | func Test_userExampleDao_Create(t *testing.T) { |
| 41 | d := newUserExampleDao() |
no test coverage detected