Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking ReJSON in a mock redis server #38

Open
kpiyush17 opened this issue Dec 24, 2019 · 3 comments
Open

Mocking ReJSON in a mock redis server #38

kpiyush17 opened this issue Dec 24, 2019 · 3 comments

Comments

@kpiyush17
Copy link

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

@nitishm
Copy link
Owner

nitishm commented Dec 25, 2019

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

@nitishm nitishm closed this as completed Dec 25, 2019
@nitishm nitishm reopened this Dec 25, 2019
@kpiyush17
Copy link
Author

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?

@morcano
Copy link

morcano commented Sep 25, 2023

Has anyone solved this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants