Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mocking Bigquery for integration test

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.

like image 774
Yuseferi Avatar asked Sep 20 '25 13:09

Yuseferi


1 Answers

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

like image 89
Vusal Shahbazov Avatar answered Sep 22 '25 22:09

Vusal Shahbazov