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
feat(pubsub): Add pubsub.AddCallbackForTesting() #2920
Conversation
Otherwise crafting a *pubsub.Message panics when Ack() is called.
Could you clarify what you mean by "crafting a *pubsub.Message panics when Ack() is called"? |
No, I didn't know of the m := pubsub.Message{Data: d}
handleMyPubsubMessage(ctx, m) and my code-under-test: func handleMyPubsubMessage(ctx context.Context, m *pubsub.Message) {
// ...
m.Ack()
} |
This proposed change replaces the client populated doneFunc (from I believe a simpler solution is to guard against calling the |
With |
Hi. Unfortunately, I'm a -1 on this. There are other ways to achieve this behavior without adding to the API surface. Please check out our new testing guide here: https://github.com/googleapis/google-cloud-go/blob/master/testing.md. |
The interesting thing is that |
This allows for simple testing. I personally prefer googleapis#2920, but I didn't win that.
We're actually looking to expose user defined ack/nack handlers for a message. This was requested recently as part of the design of the pubsub lite library which will share the same Thanks for your patience! |
This allows for simple testing. I personally prefer #2920, but I didn't win that. Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com>
One idea is to define an interface with the functions you need, one of which is Another idea is to create your own client type that wraps the |
Closing in favor of #3200 |
Add pubsub.AddCallbackForTesting()
Otherwise crafting a *pubsub.Message panics when Ack() is called.