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

Cannot properly test pipeline #30

Open
patrick-janeiro opened this issue Mar 1, 2022 · 2 comments
Open

Cannot properly test pipeline #30

patrick-janeiro opened this issue Mar 1, 2022 · 2 comments

Comments

@patrick-janeiro
Copy link

I am writing unit tests to test our pipeline code. We ran into an issue that a BeforePipelineProcess hook is propagating the first error to all CMDs.

Example code:

`
redisDB, redisMock := redismock.NewClientMock()
redisMock.ExpectGet("key1").SetErr(Errors.New("error"))
redisMock.ExpectGet("key2").SetVal("{"key":"key2","value":"value2"}")

`

when using this setup for my mock client with the following code:

pipeline := c.client.Pipeline() defer pipeline.Close() redisResults := make([]*redis.StringCmd, len(keys)) for i, key := range keys { redisResults[i] = pipeline.Get(ctx, key) } _, _ = pipeline.Exec(ctx)

I see that redisResults has "error" for all stringCmd results, instead of just the first CMD for key1.

We tested the same code with a redis instance and got the expected result of the first cmd returning an error but the second being nil.

@Maimonator
Copy link

I experience the same error

@korprulu
Copy link

this problem is made by the go-redis, take a look at code here

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