bqfake

package
v0.1.67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package bqfake provides tools to construct fake bigquery datasets, tables, query responses, etc. DEPRECATED - please use cloudtest/bqfake instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	bqiface.Client
	// contains filtered or unexported fields
}

Client implements a fake client.

func NewClient

func NewClient(ctx context.Context, project string, ds map[string]*Dataset, opts ...option.ClientOption) (*Client, error)

NewClient creates a new Client implementing bqiface.Client, with a dry run HTTPClient.

func NewQueryReadClient

func NewQueryReadClient(qc QueryConfig) *Client

func (Client) Dataset

func (client Client) Dataset(name string) bqiface.Dataset

Dataset creates a Dataset. TODO - understand how bqiface adapters/structs work, and make this return a Dataset that satisfies bqiface.Dataset interface?

func (Client) Query

func (client Client) Query(string) bqiface.Query

type ClientConfig

type ClientConfig struct {
	QueryConfig
}

ClientConfig contains configuration for injecting result and error values.

type CountingTransport

type CountingTransport struct {
	// contains filtered or unexported fields
}

CountingTransport counts calls, and returns OK and empty body. `count` field should only be accessed using atomic.Foobar

func DryRunClient

func DryRunClient() (*http.Client, *CountingTransport)

DryRunClient returns a client that just counts calls.

func (*CountingTransport) Count

func (ct *CountingTransport) Count() int32

Count returns the client call count.

func (*CountingTransport) Requests

func (ct *CountingTransport) Requests() []*http.Request

Requests returns the entire req from the last request

func (*CountingTransport) RoundTrip

func (ct *CountingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface, logging the request, and the response body, (which may be json).

type Dataset

type Dataset struct {
	bqiface.Dataset
	// contains filtered or unexported fields
}

Dataset implements part of the bqiface.Dataset interface.

func NewDataset added in v0.1.61

func NewDataset(t map[string]*Table, md *bqiface.DatasetMetadata, err error) *Dataset

NewDataset returns a new instance of Dataset.

func (Dataset) Create added in v0.1.61

func (ds Dataset) Create(ctx context.Context, md *bqiface.DatasetMetadata) error

Create returns an error.

func (Dataset) Metadata added in v0.1.61

func (ds Dataset) Metadata(ctx context.Context) (*bqiface.DatasetMetadata, error)

Metadata implements the bqiface method.

func (Dataset) Table

func (ds Dataset) Table(name string) bqiface.Table

Table implements the bqiface method.

type Job

type Job struct {
	bqiface.Job
	// contains filtered or unexported fields
}

Job implements parts of bqiface.Job to allow some very basic unit tests.

func NewJob added in v0.1.62

func NewJob(status *bigquery.JobStatus, config QueryConfig, err error) *Job

NewJob returns a new instance of Job.

func (Job) LastStatus added in v0.1.67

func (j Job) LastStatus() *bigquery.JobStatus

func (Job) Read added in v0.1.67

func (Job) Wait

func (j Job) Wait(context.Context) (*bigquery.JobStatus, error)

Wait returns a *bigquery.JobStatus and an error.

type Loader added in v0.1.62

type Loader struct {
	bqiface.Loader
	// contains filtered or unexported fields
}

Loader implements parts of bqiface.Loader to allow for testing.

func NewLoader added in v0.1.62

func NewLoader(job *Job, err error) *Loader

NewLoader returns a new instance of Loader.

func (Loader) Run added in v0.1.62

func (l Loader) Run(ctx context.Context) (bqiface.Job, error)

Run returns a bqiface.Job and an error.

func (Loader) SetLoadConfig added in v0.1.63

func (l Loader) SetLoadConfig(config bqiface.LoadConfig)

SetLoadConfig does nothing.

type Query

type Query struct {
	bqiface.Query
	// contains filtered or unexported fields
}

Query implements parts of bqiface.Query to allow some very basic unit tests.

func (Query) Read

func (Query) Run

func (q Query) Run(context.Context) (bqiface.Job, error)

func (Query) SetQueryConfig

func (q Query) SetQueryConfig(bqiface.QueryConfig)

SetQueryConfig is used to set the ReadErr or RowIteratorConfig.

type QueryConfig

type QueryConfig struct {
	ReadErr error
	RowIteratorConfig
}

QueryConfig contains configuration for injecting query results and error values.

type RowIterator

type RowIterator struct {
	bqiface.RowIterator
	// contains filtered or unexported fields
}

func (*RowIterator) Next

func (r *RowIterator) Next(dst interface{}) error

type RowIteratorConfig

type RowIteratorConfig struct {
	IterErr error
	Rows    []map[string]bigquery.Value
}

RowIteratorConfig contains configuration for injecting row iteration results and error values.

type Table

type Table struct {
	bqiface.Table
	// contains filtered or unexported fields
}

Table implements part of the bqiface.Table interface required for basic testing Other parts of the interface should be implemented as needed.

func NewTable added in v0.1.61

func NewTable(opts TableOpts) *Table

NewTable returns a new instance of Table.

func (Table) Create

func (tbl Table) Create(ctx context.Context, meta *bigquery.TableMetadata) error

Create implements the bqiface method.

func (Table) DatasetID

func (tbl Table) DatasetID() string

DatasetID implements the bqiface method.

func (Table) FullyQualifiedName

func (tbl Table) FullyQualifiedName() string

FullyQualifiedName implements the bqiface method.

func (Table) LoaderFrom added in v0.1.62

func (tbl Table) LoaderFrom(src bigquery.LoadSource) bqiface.Loader

LoaderFrom returns a bqiface.Loader.

func (Table) Metadata

func (tbl Table) Metadata(ctx context.Context) (*bigquery.TableMetadata, error)

Metadata implements the bqiface method.

func (Table) ProjectID

func (tbl Table) ProjectID() string

ProjectID implements the bqiface method.

func (Table) TableID

func (tbl Table) TableID() string

TableID implements the bqiface method.

func (Table) Update added in v0.1.61

Update updates the table's `Schema`.

type TableOpts added in v0.1.62

type TableOpts struct {
	Dataset
	Name      string
	Metadata  *bigquery.TableMetadata
	Loader    bqiface.Loader
	Error     error
	UpdateErr error
}

TableOpts defines field options for Table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL