()
| 20 | ) |
| 21 | |
| 22 | func newUserExampleService() *gotest.Service { |
| 23 | testData := &model.UserExample{} |
| 24 | testData.ID = 1 |
| 25 | // you can set the other fields of testData here, such as: |
| 26 | //testData.CreatedAt = time.Now() |
| 27 | //testData.UpdatedAt = testData.CreatedAt |
| 28 | |
| 29 | // init mock cache |
| 30 | c := gotest.NewCache(map[string]interface{}{utils.Uint64ToStr(testData.ID): testData}) |
| 31 | c.ICache = cache.NewUserExampleCache(&database.CacheType{ |
| 32 | CType: "redis", |
| 33 | Rdb: c.RedisClient, |
| 34 | }) |
| 35 | |
| 36 | // init mock dao |
| 37 | d := gotest.NewDao(c, testData) |
| 38 | d.IDao = dao.NewUserExampleDao(d.DB, c.ICache.(cache.UserExampleCache)) |
| 39 | |
| 40 | // init mock service |
| 41 | s := gotest.NewService(d, testData) |
| 42 | serverNameExampleV1.RegisterUserExampleServer(s.Server, &userExample{ |
| 43 | UnimplementedUserExampleServer: serverNameExampleV1.UnimplementedUserExampleServer{}, |
| 44 | iDao: d.IDao.(dao.UserExampleDao), |
| 45 | }) |
| 46 | |
| 47 | // start up rpc server |
| 48 | s.GoGrpcServer() |
| 49 | time.Sleep(time.Millisecond * 100) |
| 50 | |
| 51 | // grpc client |
| 52 | s.IServiceClient = serverNameExampleV1.NewUserExampleClient(s.GetClientConn()) |
| 53 | |
| 54 | return s |
| 55 | } |
| 56 | |
| 57 | func Test_userExampleService_Create(t *testing.T) { |
| 58 | s := newUserExampleService() |
no test coverage detected