testutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// KvMeta is the Metadata for mocked KV table.
	KvMeta = sppb.ResultSetMetadata{
		RowType: &sppb.StructType{
			Fields: []*sppb.StructType_Field{
				{
					Name: "Key",
					Type: &sppb.Type{Code: sppb.TypeCode_STRING},
				},
				{
					Name: "Value",
					Type: &sppb.Type{Code: sppb.TypeCode_STRING},
				},
			},
		},
	}
)

Functions

func DecodeResumeToken

func DecodeResumeToken(t []byte) (uint64, error)

DecodeResumeToken decodes a mock resume token into an uint64 integer.

func EncodeResumeToken

func EncodeResumeToken(t uint64) []byte

EncodeResumeToken return mock resume token encoding for an uint64 integer.

Types

type Action

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

Action is a mocked RPC activity that MockCloudSpannerClient will take.

func NewAction

func NewAction(m string, e error) Action

NewAction creates Action objects.

type MockCloudSpanner

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

MockCloudSpanner is a mock implementation of SpannerServer interface. TODO: make MockCloudSpanner a full-fleged Cloud Spanner implementation.

func NewMockCloudSpanner

func NewMockCloudSpanner(t *testing.T, ts time.Time) *MockCloudSpanner

NewMockCloudSpanner creates a new MockCloudSpanner instance.

func (*MockCloudSpanner) AddMsg

func (m *MockCloudSpanner) AddMsg(err error, resumeToken bool)

AddMsg generates a new mocked row which can be received by client.

func (*MockCloudSpanner) Addr

func (m *MockCloudSpanner) Addr() string

Addr returns the listening address of mock server.

func (*MockCloudSpanner) BeginTransaction

BeginTransaction is a placeholder for SpannerServer.BeginTransaction.

func (*MockCloudSpanner) Commit

Commit is a placeholder for SpannerServer.Commit.

func (*MockCloudSpanner) CreateSession

CreateSession is a placeholder for SpannerServer.CreateSession.

func (*MockCloudSpanner) DeleteSession

DeleteSession is a placeholder for SpannerServer.DeleteSession.

func (*MockCloudSpanner) Done

func (m *MockCloudSpanner) Done()

Done signals an end to a mocked stream.

func (*MockCloudSpanner) ExecuteSql

ExecuteSql is a placeholder for SpannerServer.ExecuteSql.

func (*MockCloudSpanner) ExecuteStreamingSql

ExecuteStreamingSql is a mock implementation of SpannerServer.ExecuteStreamingSql.

func (*MockCloudSpanner) GetSession

GetSession is a placeholder for SpannerServer.GetSession.

func (*MockCloudSpanner) Read

Read is a placeholder for SpannerServer.Read.

func (*MockCloudSpanner) Rollback

Rollback is a placeholder for SpannerServer.Rollback.

func (*MockCloudSpanner) Serve

func (m *MockCloudSpanner) Serve()

Serve runs a MockCloudSpanner listening on a random localhost address.

func (*MockCloudSpanner) Stop

func (m *MockCloudSpanner) Stop()

Stop terminates MockCloudSpanner and closes the serving port.

func (*MockCloudSpanner) StreamingRead

StreamingRead is a placeholder for SpannerServer.StreamingRead.

type MockCloudSpannerClient

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

MockCloudSpannerClient is a mock implementation of sppb.SpannerClient.

func NewMockCloudSpannerClient

func NewMockCloudSpannerClient(t *testing.T, acts ...Action) *MockCloudSpannerClient

NewMockCloudSpannerClient creates new MockCloudSpannerClient instance.

func (*MockCloudSpannerClient) BeginTransaction

BeginTransaction is a placeholder for SpannerClient.BeginTransaction.

func (*MockCloudSpannerClient) Commit

Commit is a placeholder for SpannerClient.Commit.

func (*MockCloudSpannerClient) CreateSession

CreateSession is a placeholder for SpannerClient.CreateSession.

func (*MockCloudSpannerClient) DeleteSession

DeleteSession is a placeholder for SpannerClient.DeleteSession.

func (*MockCloudSpannerClient) DumpPings

func (m *MockCloudSpannerClient) DumpPings() []string

DumpPings dumps the ping history.

func (*MockCloudSpannerClient) DumpSessions

func (m *MockCloudSpannerClient) DumpSessions() map[string]bool

DumpSessions dumps the internal session table.

func (*MockCloudSpannerClient) ExecuteSql

ExecuteSql is a placeholder for SpannerClient.ExecuteSql.

func (*MockCloudSpannerClient) ExecuteStreamingSql

ExecuteStreamingSql is a mock implementation of SpannerClient.ExecuteStreamingSql.

func (*MockCloudSpannerClient) Freeze added in v0.11.0

func (m *MockCloudSpannerClient) Freeze()

Freeze stalls all requests.

func (*MockCloudSpannerClient) GetSession

GetSession is a placeholder for SpannerClient.GetSession.

func (*MockCloudSpannerClient) InjectError

func (m *MockCloudSpannerClient) InjectError(method string, err error)

InjectError injects a global error that will be returned by all APIs regardless of the actions array.

func (*MockCloudSpannerClient) MakeNice

func (m *MockCloudSpannerClient) MakeNice()

MakeNice makes this a nice mock which will not fail on any request.

func (*MockCloudSpannerClient) MakeStrict

func (m *MockCloudSpannerClient) MakeStrict()

MakeStrict makes this a strict mock which will fail on any unexpected request.

func (*MockCloudSpannerClient) Read

Read is a placeholder for SpannerClient.Read.

func (*MockCloudSpannerClient) Rollback

Rollback is a placeholder for SpannerClient.Rollback.

func (*MockCloudSpannerClient) SetActions

func (m *MockCloudSpannerClient) SetActions(acts ...Action)

SetActions sets the new set of expected actions to MockCloudSpannerClient.

func (*MockCloudSpannerClient) StreamingRead

StreamingRead is a placeholder for SpannerClient.StreamingRead.

func (*MockCloudSpannerClient) Unfreeze added in v0.11.0

func (m *MockCloudSpannerClient) Unfreeze()

Unfreeze restores processing requests.

type MockCtlMsg

type MockCtlMsg struct {
	// If ResumeToken == true, mock server will generate a row with
	// resume token.
	ResumeToken bool
	// If Err != nil, mock server will return error in RPC response.
	Err error
}

MockCtlMsg encapsulates PartialResultSet/error that might be sent to client

Jump to

Keyboard shortcuts

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