Ignore calls to Ack/Nack if the doneFunc isn't set (#3139)
This allows for simple testing.
I personally prefer https://github.com/googleapis/google-cloud-go/pull/2920, but I didn't win that.
Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com>
diff --git a/pubsub/message.go b/pubsub/message.go
index 13dfbc6..00076ef 100644
--- a/pubsub/message.go
+++ b/pubsub/message.go
@@ -119,5 +119,7 @@
return
}
m.calledDone = true
- m.doneFunc(m.ackID, ack, m.receiveTime)
+ if m.doneFunc != nil {
+ m.doneFunc(m.ackID, ack, m.receiveTime)
+ }
}