pubsub/pstest: add TopicID field to the Message struct
Is your feature request related to a problem? Please describe.
Right now there is no way to identify the topic id of a pstest.Message that returned from calling pstest.Server.Messages method.
Describe the solution you'd like
Create a new TopicID field in pstest.Message and ensure that it gets populated when a client is publishing to the fake server.
Describe alternatives you've considered
None, I believe the first solution is pretty straightforward and quite trivial to implement.
Additional context
I can help contribute to this feature request on approval.
Could you elaborate a bit more on why this might be helpful for you from a testing perspective?
Sure! I'm currently writing a package that can automatically route to multiple Pub/Sub topics. In the unit test, I will need to check whether the package routes (or in this case publishes) to the correct topic or not.
Right now, because of there's no topic ID information in the Message, I need to manually create a subscription for each topic. Then, I will need to consume each one of the subscription and join them back again with a topic ID information added. I believe that these type of tests can be greatly simplified if I can just look into the topic information directly on the published messages.
Yeah that seems fine to me. If you create a PR for this, I'll be happy to review and help get it merged in.
@hongalex Thanks! I created the PR at #10510.
Thank you for the help! This should be added to the next release.