PhilAndrew / mockgenredisv9

mockgenredisv9
0 stars 1 forks source link

The problem of test run failure #1

Open HsqSw opened 1 year ago

HsqSw commented 1 year ago

redis.MGet only accepts two params. First is context, Second is a string slice. So you can try change as this: mockRedis.EXPECT().MGet(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(context context.Context, cacheKey string, deleteKey string) -> mockRedis.EXPECT().MGet(gomock.Any(), gomock.Any()).DoAndReturn(func(context context.Context, keys string...)

albaizzz commented 1 year ago

refer from this sample about variadic parameter handling in gomock https://github.com/golang/mock/blob/main/mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go The solution is you should change mockRedis.EXPECT().MGet(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(context context.Context, cacheKey string, deleteKey string) redis.SliceCmd { to > mockRedis.EXPECT().MGet(gomock.Any(), gomock.Any()).DoAndReturn(func(context context.Context, args ...string) redis.SliceCmd {