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

fix: cmd error in pipelines #90

Closed

Conversation

jonasmeier1212
Copy link

When a command in a pipeline produces an error, only this single command should fail and return an error.

However the currently implemented behavior is that the complete pipeline execution fails, which isn't resembling the behavior from Redis.

Example:

func toBeTested(redis *redis.Client) {
  pipe := redis.Pipeline()

  pipe.Get("key1")
  pipe.Get("key2")

  cmds, err := pipe.Exec()
  // The behavior of Redis is that `err=nil`, although the seconds command will return a `redis.Nil` error.
  // cmds[1].Err() should be `redis.Nil`
  // The redismock implemention however returns already here `redis.Nil` error, which is wrong behavior. 
}

func Test_1(t *testing.T) {
  redisClient, mock := redismock.NewClientMock()

  mock.ExpectGet("key1").SetVal("val1")
  mock.ExpectGet("key2").RedisNil()

  toBeTested(redisClient)
}

When a command in a pipeline produces an error, only this single command should fail and return an error.

However the currently implemented behavior is that the complete pipeline execution fails, which isn't resembling the behavior from Redis.
@jonasmeier1212
Copy link
Author

Actually that's the real behavior of go-redis: redis/go-redis#1860

So this PR is irrelevant and wrong.

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

Successfully merging this pull request may close these issues.

1 participant