go-gcp-pubsub-test-demo

command module
v0.0.0-...-be94382 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 4 Imported by: 0

README

Go Cloud Pubsub Unit-test Demo

A project which demonstrates how we can test GCP services SDK that don't expose interface. The idea is to define our own interface and wrap the SDK struct so we can generate a mock using gomock.

See the full article here https://medium.com/@albertsundjaja/unit-test-gcp-services-in-go-965bda40d539

Code walkthrough

mock contains the mock of the interfaces that were generated by gomock

pubsub_client contains our interface that we defined to wrap the GCP PubSub client

pubsub_service is our main class that contains the method that we want to unit test. It uses pubsub_client to connect to GCP PubSub

main.go is the entry point which demonstrates how we can construct the pubsub_client and pubsub_service and glue them together

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package mock_pubsub is a generated GoMock package.
Package mock_pubsub is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL