I'm using https://github.com/googleapis/google-cloud-go to interact with GCP Bigquery to fetch some data.
I want to write some tests for my code. for the unit testing, it's easy because I can mock my repository ( data layer) and return what I expected for.
I'm looking for writing an integration test, if it was just basic HTTP I could write a httptest server and return some dummy ( fake) data. but this library is using gRPC to communicate with GCP Bigquery.
I'm wondering how I can write an integration test for GCP Bigquery in Golang.
let's keep it in the simplest way and just provide the integration part for Query a table in a dataset and read data
.
You can run dependency locally. Read : Docker container for Google BigQuery
You can write script for running tests and dependencies(BigQuery) in docker container
If you dont want to run test using docker you can use bigquery-emulator
Or just mock it Send your repository(data layer) as interface to your http server And then you run test use mock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With