go-redis / redismock

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

support for client.Watch #5

Closed bstpierre closed 3 years ago

bstpierre commented 3 years ago

Similar to issue #2, can we have support for Watch?

I have code like:

txf := func(tx *redis.Tx) error {
    val, err := tx.Get(ctx, "mykey").Int64()
    err = tx.Set(ctx, "mykey", val + 1, 0).Err()
}

err := client.Watch(ctx, txf, "mykey")

If my test code uses mock.ExpectGet("mykey") then I get:

parameters do not match, expectation '[get mykey]', but call to cmd '[watch mykey]'

I don't see anything in the code that will expect a WATCH. Is there a way to achieve this or does it need a patch?

Thank you.