How to mock Google BigQuery client in Golang
Whats the problem?
The official Google BigQuery packge for Golang is cloud.google.com/go/bigquery and when you create a client it returns a specific struct instead of an interface. This is a bit confusing, because even though it allow maintainers to add new methods to the bigquery client without worry that it would break consumers, it makes unit testing a bit more complex.
With a specific struct returned you can no longer simply sketch an object that fullfil the interface requirements or use mockery to do it for you. Suppose you have this toy example which prints the data from a table: