Open marclop opened 1 year ago
Hi @marclop. The mock server in pubsublite/internal/test
requires deep knowledge of the Pub/Sub Lite wire protocol, which would be cumbersome for you to use. It's not a true fake like the one in pubsub/pstest
. We are working on an emulator for Pub/Sub Lite though. Would that be useful for your testing?
@tmdiep I see. I didn't look into how it was used.
Will the emulator be similar to the current pubsub
emulator? We'd like to avoid spinning containers for unit tests since it makes them quite slow and introduces more dependencies than I'd like.
Yes, the emulator would be similar to the pubsub
emulator. In fact, you could probably use that right now as a substitute, since Pub/Sub Lite implements publisher and subscriber interfaces that are compatible with the pubsub
ones.
I was going to suggest that you define interfaces, but you've considered this already (from the description). We would probably need to allow types such as PublishResult
createable, as requested in https://github.com/googleapis/google-cloud-go/issues/7801. Tagging @hongalex for consideration.
Is your feature request related to a problem? Please describe.
We're working on some Golang code that uses GCP PubSubLite, and would like to leverage the already existing (and pretty complete) test package that is available in
cloud.google.com/go/pubsublite/internal/test
for our unit tests. We're not aiming to test the absolute correctness of GCP PubSubLite, but more of our code that's built on top of the GCP PubSubLite SDK.Rather than add an abstraction layer in our side, which is the other alternative, I think it would be good to expose the already built
internal/test
package that you folks have created.Describe the solution you'd like
Would exposing
cloud.google.com/go/pubsublite/internal/test.NewServer
aspubsublite/test
work? I can't imagine that we're the only people that have asked for this.There's already precedent for this in https://pkg.go.dev/cloud.google.com/go/pubsub@v1.30.0/pstest
Describe alternatives you've considered
We could instead abstract the client creation and add more interfaces in our code, but I don't see a whole lot of benefit in doing that when there's already a very decent mock available to use from the upstream library.
Additional context Add any other context or screenshots about the feature request here.