go-redis / redismock

Redis client Mock
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
272 stars 59 forks source link

过期时间如何进行通配 #10

Closed Allen-ZhangM closed 3 years ago

Allen-ZhangM commented 3 years ago

比如ExpectSet这种,一定要设置一个过期时间,但是代码中有些过期时间是随机的导致匹配不上。 报错如下 args not DeepEqual, expectation: '0', but gave: '48308' expire是否可以像value一样用regexp通配? 或者用什么方式不用DeepEqual?

monkey92t commented 3 years ago

you can try:

mock.CustomMatch(func(expected, actual []interface{}) error {
        // Custom matching

        return nil
}).ExpectSet("key", "value", 100 * time.Second).SetErr(errors.New("test error"))