mock

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultJWTToken dummy token
	DefaultJWTToken = "" /* 469-byte string literal not displayed */
)
View Source
const (

	// SQLPasswordStorageResponse mocked
	SQLPasswordStorageResponse = `` /* 130-byte string literal not displayed */

)

Variables

View Source
var (
	// RetrieveTokenForbiddenHTTPMock request
	RetrieveTokenForbiddenHTTPMock = NewMockedHTTPRequest("POST", "/token", forbiddenResponse)
	// RetrieveAccessTokenHTTPMock request
	RetrieveAccessTokenHTTPMock = NewMockedHTTPRequest("POST", "/token", accessTokenResponse)
	// OauthHTTPMock request
	OauthHTTPMock = NewMockedHTTPRequest("POST", "/o/oauth2/token", oauthResponse)
	// ImpersonationHTTPMock request
	ImpersonationHTTPMock = NewMockedHTTPRequest("POST", "/v1/projects/-/serviceAccounts/.*:generateAccessToken", impersonateResponse)

	// ObjectsExistsHTTPMock request
	ObjectsExistsHTTPMock = NewMockedHTTPRequest("GET", "/storage/v1/b/.*/o", objectsExistsResponse)
	// SinkNotExistsHTTPMock request
	SinkNotExistsHTTPMock = NewMockedHTTPRequest("GET", "/storage/v1/b", sinkNotexistsResponse)
	// BucketAttrsHTTPMock request
	BucketAttrsHTTPMock = NewMockedHTTPRequest("GET", "/storage/v1/b/.*", bucketAttrsResponse)
	// PatchBucketAttrsHTTPMock request
	PatchBucketAttrsHTTPMock = NewMockedHTTPRequest("PATCH", "/storage/v1/b/.*", patchBucketAttrsResponse)
	// SinkCreatedHTTPpMock request
	SinkCreatedHTTPpMock = NewMockedHTTPRequest("POST", "/storage/v1/b", sinkCreatedResponse)
	// SinkDeletedHTTPMock request
	SinkDeletedHTTPMock = NewMockedHTTPRequest("DELETE", "/storage/v1/b", sinkDeletedResponse)
	// DatasetNotAllowedInfoHTTPMock request
	DatasetNotAllowedInfoHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/not-allowed-dataset", datasetInfoNotAllowedResponse)
	// DatasetNotFoundInfoHTTPMock request
	DatasetNotFoundInfoHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/unknown-dataset", datasetInfoNotFoundResponse)
	// DatasetInfoHTTPMock request
	DatasetInfoHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/.*", datasetInfoResponse)

	// TableNotFoundMock request
	TableNotFoundMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/.*/tables/notExistingTable", tableInfoNotFoundResponse)

	// TableInfoHTTPMock request
	TableInfoHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/.*/tables/.*", tableInfoResponse)
	// TablePartitionQueryHTTPMock request
	TablePartitionQueryHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/datasets/.*/tables/.*/data", hasTablePartitionsResponse)
	// TablePartitionJobHTTPMock request
	TablePartitionJobHTTPMock = NewMockedHTTPRequest("POST", "/bigquery/v2/projects/.*/jobs", getTablePartitionsJobResponse)
	// TablePartitionResultHTTPMock request
	TablePartitionResultHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/queries", getTablePartitionsQueryResponse)
	// ExtractJobResultOkHTTPMock request
	ExtractJobResultOkHTTPMock = NewMockedHTTPRequest("GET", "/bigquery/v2/projects/.*/jobs/.*", getExtractJobResultOkResponse)
)

Functions

This section is empty.

Types

type HTTPMockHandler

type HTTPMockHandler struct {
}

HTTPMockHandler handles requests

func NewHTTPMockHandler

func NewHTTPMockHandler() *HTTPMockHandler

NewHTTPMockHandler return instance of HTTPMockHandler

func (*HTTPMockHandler) Cleanup

func (h *HTTPMockHandler) Cleanup()

Cleanup reset transport

func (*HTTPMockHandler) Register

func (h *HTTPMockHandler) Register(httpMocks ...MockedHTTPRequest)

register one or more MockedHTTPRequest

func (*HTTPMockHandler) RegisterLocalServer

func (h *HTTPMockHandler) RegisterLocalServer(localServer string, methods ...string)

RegisterLocalServer set local server

func (*HTTPMockHandler) Sniff

func (h *HTTPMockHandler) Sniff()

Sniff return response

func (*HTTPMockHandler) Start

func (h *HTTPMockHandler) Start()

Start handling request

func (*HTTPMockHandler) Stop

func (h *HTTPMockHandler) Stop()

Stop reset transport

type MockedHTTPRequest

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

MockedHTTPRequest mock http requests

func NewMockedHTTPRequest

func NewMockedHTTPRequest(method string, path string, response string) MockedHTTPRequest

NewMockedHTTPRequest return instance of MockedHTTPRequest

func NewMockedHTTPRequestWithQuery

func NewMockedHTTPRequestWithQuery(method string, path string, response string, query map[string]string) MockedHTTPRequest

NewMockedHTTPRequestWithQuery return instance of MockedHTTPRequest with query

func (MockedHTTPRequest) String

func (m MockedHTTPRequest) String() string

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

RoundTripperFunc callable definition

func (RoundTripperFunc) RoundTrip

func (fn RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip calls RoundTripperFunc

Jump to

Keyboard shortcuts

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