Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arhea/go-mock-bigquery
Creates a mock BigQuery client based on the bigquery-emulator for testing in Golang projects.
https://github.com/arhea/go-mock-bigquery
bigquery golang golang-module google-bigquery google-cloud-platform testcontainers-go testing
Last synced: about 1 month ago
JSON representation
Creates a mock BigQuery client based on the bigquery-emulator for testing in Golang projects.
- Host: GitHub
- URL: https://github.com/arhea/go-mock-bigquery
- Owner: arhea
- License: mit
- Created: 2024-01-06T01:12:49.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-10T00:38:25.000Z (7 months ago)
- Last Synced: 2024-09-29T06:21:40.565Z (about 2 months ago)
- Topics: bigquery, golang, golang-module, google-bigquery, google-cloud-platform, testcontainers-go, testing
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Mock BigQuery Emulator
![Tests](https://github.com/arhea/go-mock-bigquery/actions/workflows/main.yml/badge.svg?branch=main) ![goreportcard](https://goreportcard.com/badge/github.com/arhea/go-mock-bigquery)
Provide a mock BigQuery Emulator instance and optionally a mock BigQuery client for testing purposes. This library is built so you can mock BigQuery using the [bigquery-emulator](https://github.com/goccy/bigquery-emulator) project. You will need to have Docker running on your local machine or within your CI environment.
This library is built on top of [testcontainers](https://testcontainers.com/).
## Usage
Creating a mock instance for creating a customer connection.
```golang
func TestXXX(t *testing.T) {
ctx := context.Background()const projectID = "test-project"
const datasetID = "test-dataset"mock, err := mockbigquery.NewInstance(ctx, t, projectID, datasetID)
if err != nil {
t.Fatalf("creating the instance: %v", err)
return
}// close the mock
defer mock.Close(ctx)// ... my test code
}
```Creating a mock redis client for interacting with Redis.
```golang
func TestXXX(t *testing.T) {
ctx := context.Background()const projectID = "test-project"
const datasetID = "test-dataset"mock, err := mockbigquery.NewClient(ctx, t, projectID, datasetID)
if err != nil {
t.Fatalf("creating the client: %v", err)
return
}// close the mock
defer mock.Close(ctx)bqClient := mock.Client()
// ... my test code
}
```