go-redis / redismock

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

add ExpectDo methods #26

Open ideasculptor opened 2 years ago

ideasculptor commented 2 years ago

Added example implementations for handling Do() with various return types. Needs to be fleshed out with all of the various potential return types and tests, but demonstrates the concept. I may eventually get around to implementing the feature in its entirety, but probably not anytime soon, unfortunately, so this PR exists largely for documentary purposes in the associated issue: https://github.com/go-redis/redismock/issues/25

ilovejs commented 1 year ago

Any progress on That?? @ideasculptor @ryantate13

ideasculptor commented 1 year ago

I'll update the PR so that it is up to date with go-redis:master but I doubt either of us is going to find ourselves with the time to do the full implementation that would be required to get someone to merge this any time soon. This fork serves our needs sufficiently as it is.

Check back in a few hours and I should have the PR updated.

ideasculptor commented 1 year ago

Check back in a few hours and I should have the PR updated.

done

monkey92t commented 1 year ago

client.Do is a special API, its return value is not a fixed data type, if you want to set the return value of int64, please refer to the example:

         // or []interface{}{int64(100), int64(200)}
    mock.ExpectDo("hkeys", "hkey").SetVal([]interface{}{"100", "200"}) 
    v, err := client.Do(ctx, "hkeys", "hkey").Int64Slice()
    t.Log(v, err)