bqfake

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 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

View Source
var (
	// ErrTypeAssertionFailed may be returned by the row iterator when the target type is incorrect.
	ErrTypeAssertionFailed = errors.New("type assertion failed")
)

Functions

This section is empty.

Types

type Client

type Client[Row any] struct {
	bqiface.Client
	// contains filtered or unexported fields
}

Client implements a fake client.

func NewClient

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

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

func NewQueryReadClient added in v0.1.20

func NewQueryReadClient[Row any](qc QueryConfig[Row]) *Client[Row]

func (Client[Row]) Dataset

func (client Client[Row]) Dataset(ds 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[Row]) Query

func (client Client[Row]) Query(string) bqiface.Query

type ClientConfig added in v0.1.20

type ClientConfig[Row any] struct {
	QueryConfig[Row]
}

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 (Dataset) Table

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

Table implements the bqiface method.

type Job

type Job struct {
	bqiface.Job
}

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

func (Job) Wait

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

type Query

type Query[Row any] struct {
	bqiface.Query
	// contains filtered or unexported fields
}

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

func (Query[Row]) Read

func (q Query[Row]) Read(context.Context) (bqiface.RowIterator, error)

func (Query[Row]) Run

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

func (Query[Row]) SetQueryConfig

func (q Query[Row]) SetQueryConfig(bqiface.QueryConfig)

SetQueryConfig is used to set the ReadErr or RowIteratorConfig.

type QueryConfig added in v0.1.20

type QueryConfig[Row any] struct {
	ReadErr error
	RowIteratorConfig[Row]
}

QueryConfig contains configuration for injecting query results and error values.

type RowIterator

type RowIterator[Row any] struct {
	bqiface.RowIterator
	// contains filtered or unexported fields
}

func (*RowIterator[Row]) Next

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

func (*RowIterator[Row]) TotalRows added in v0.1.60

func (r *RowIterator[Row]) TotalRows() uint64

type RowIteratorConfig added in v0.1.20

type RowIteratorConfig[Row any] struct {
	IterErr error
	Rows    []Row
}

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 (Table) Create

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

Create implements the bqiface method. DEPRECATED - use cloudtest/bqfake

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) 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.

Jump to

Keyboard shortcuts

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