Mocking ReJSON in a mock redis server
kpiyush17 opened this issue · comments
Is there any way to mock rejson in a mocked Redis server in golang?
I am able to mock a Redis server using something like this using miniredis and redismock
func newTestRedis() (*redismock.ClientMock, *redis.Client) {
mr, err := miniredis.Run()
if err != nil {
panic(err)
}
client := redis.NewClient(&redis.Options{
Addr: mr.Addr(),
})
return redismock.NewNiceMock(client.Client), client
}
It is able to do normal Redis operations like Get, Set but since I am using ReJSON module, I am not able to run any ReJSON commands on that.
Thanks
You can use something like mockery and testify to generate mocks using the ReJSON interface - https://github.com/nitishm/go-rejson/blob/master/rejson.go#L17
But If I use the ReJSON interface to generate mocks, I have to create a struct(other than Handler) that implements all the methods of the ReJSON interface even if I am not using that method.
Can you provide an example?
Has anyone solved this?