Skip to content

Commit

Permalink
deal with google client mock
Browse files Browse the repository at this point in the history
  • Loading branch information
nehhhhha6 committed Oct 8, 2024
1 parent fb13661 commit 8dc4057
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Empty file added mocks/bigquery_client_mock.go
Empty file.
23 changes: 23 additions & 0 deletions services/ bigquery_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package bigqueryclient

import (
"context"
"cloud.google.com/go/bigquery"
)

// BigQueryClient defines the interface for the BigQuery client
type BigQueryClient interface {
CreateTable(ctx context.Context, datasetID string, tableID string, schema bigquery.Schema) error
}

// MyBigQueryClient implements the BigQueryClient interface
type MyBigQueryClient struct {
client *bigquery.Client
}

// CreateTable creates a new table in BigQuery
func (m *MyBigQueryClient) CreateTable(ctx context.Context, datasetID string, tableID string, schema bigquery.Schema) error {
table := m.client.Dataset(datasetID).Table(tableID)
return table.Create(ctx, &bigquery.TableMetadata{Schema: schema})
}
Empty file added services/myservice.go
Empty file.
Empty file added services/myservice_test.go
Empty file.

0 comments on commit 8dc4057

Please sign in to comment.