Documentation ¶
Index ¶
- Variables
- func DecodeResumeToken(t []byte) (uint64, error)
- func EncodeResumeToken(t uint64) []byte
- type Action
- type MockCloudSpanner
- func (m *MockCloudSpanner) AddMsg(err error, resumeToken bool)
- func (m *MockCloudSpanner) Addr() string
- func (m *MockCloudSpanner) CreateSession(c context.Context, r *sppb.CreateSessionRequest) (*sppb.Session, error)
- func (m *MockCloudSpanner) DeleteSession(c context.Context, r *sppb.DeleteSessionRequest) (*empty.Empty, error)
- func (m *MockCloudSpanner) Done()
- func (m *MockCloudSpanner) ExecuteStreamingSql(r *sppb.ExecuteSqlRequest, s sppb.Spanner_ExecuteStreamingSqlServer) error
- func (m *MockCloudSpanner) GetSession(c context.Context, r *sppb.GetSessionRequest) (*sppb.Session, error)
- func (m *MockCloudSpanner) Serve()
- func (m *MockCloudSpanner) Stop()
- func (m *MockCloudSpanner) StreamingRead(r *sppb.ReadRequest, s sppb.Spanner_StreamingReadServer) error
- type MockCloudSpannerClient
- func (m *MockCloudSpannerClient) BeginTransaction(c context.Context, r *sppb.BeginTransactionRequest, opts ...grpc.CallOption) (*sppb.Transaction, error)
- func (m *MockCloudSpannerClient) CheckActionsConsumed()
- func (m *MockCloudSpannerClient) Commit(c context.Context, r *sppb.CommitRequest, opts ...grpc.CallOption) (*sppb.CommitResponse, error)
- func (m *MockCloudSpannerClient) CreateSession(c context.Context, r *sppb.CreateSessionRequest, opts ...grpc.CallOption) (*sppb.Session, error)
- func (m *MockCloudSpannerClient) DeleteSession(c context.Context, r *sppb.DeleteSessionRequest, opts ...grpc.CallOption) (*empty.Empty, error)
- func (m *MockCloudSpannerClient) DumpPings() []string
- func (m *MockCloudSpannerClient) DumpSessions() map[string]bool
- func (m *MockCloudSpannerClient) ExecuteStreamingSql(c context.Context, r *sppb.ExecuteSqlRequest, opts ...grpc.CallOption) (sppb.Spanner_ExecuteStreamingSqlClient, error)
- func (m *MockCloudSpannerClient) Freeze()
- func (m *MockCloudSpannerClient) GetSession(c context.Context, r *sppb.GetSessionRequest, opts ...grpc.CallOption) (*sppb.Session, error)
- func (m *MockCloudSpannerClient) InjectError(method string, err error)
- func (m *MockCloudSpannerClient) MakeNice()
- func (m *MockCloudSpannerClient) MakeStrict()
- func (m *MockCloudSpannerClient) PartitionQuery(ctx context.Context, r *sppb.PartitionQueryRequest, opts ...grpc.CallOption) (*sppb.PartitionResponse, error)
- func (m *MockCloudSpannerClient) PartitionRead(ctx context.Context, r *sppb.PartitionReadRequest, opts ...grpc.CallOption) (*sppb.PartitionResponse, error)
- func (m *MockCloudSpannerClient) Rollback(c context.Context, r *sppb.RollbackRequest, opts ...grpc.CallOption) (*empty.Empty, error)
- func (m *MockCloudSpannerClient) SetActions(acts ...Action)
- func (m *MockCloudSpannerClient) StreamingRead(c context.Context, r *sppb.ReadRequest, opts ...grpc.CallOption) (sppb.Spanner_StreamingReadClient, error)
- func (m *MockCloudSpannerClient) Unfreeze()
- type MockCtlMsg
Constants ¶
This section is empty.
Variables ¶
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 ¶
DecodeResumeToken decodes a mock resume token into an uint64 integer.
func EncodeResumeToken ¶
EncodeResumeToken return mock resume token encoding for an uint64 integer.
Types ¶
type MockCloudSpanner ¶
type MockCloudSpanner struct { sppb.SpannerServer // 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) CreateSession ¶
func (m *MockCloudSpanner) CreateSession(c context.Context, r *sppb.CreateSessionRequest) (*sppb.Session, error)
CreateSession is a placeholder for SpannerServer.CreateSession.
func (*MockCloudSpanner) DeleteSession ¶
func (m *MockCloudSpanner) DeleteSession(c context.Context, r *sppb.DeleteSessionRequest) (*empty.Empty, error)
DeleteSession is a placeholder for SpannerServer.DeleteSession.
func (*MockCloudSpanner) Done ¶
func (m *MockCloudSpanner) Done()
Done signals an end to a mocked stream.
func (*MockCloudSpanner) ExecuteStreamingSql ¶
func (m *MockCloudSpanner) ExecuteStreamingSql(r *sppb.ExecuteSqlRequest, s sppb.Spanner_ExecuteStreamingSqlServer) error
ExecuteStreamingSql is a mock implementation of SpannerServer.ExecuteStreamingSql.
func (*MockCloudSpanner) GetSession ¶
func (m *MockCloudSpanner) GetSession(c context.Context, r *sppb.GetSessionRequest) (*sppb.Session, error)
GetSession is a placeholder for SpannerServer.GetSession.
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 ¶
func (m *MockCloudSpanner) StreamingRead(r *sppb.ReadRequest, s sppb.Spanner_StreamingReadServer) error
StreamingRead is a placeholder for SpannerServer.StreamingRead.
type MockCloudSpannerClient ¶
type MockCloudSpannerClient struct { sppb.SpannerClient // 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 ¶
func (m *MockCloudSpannerClient) BeginTransaction(c context.Context, r *sppb.BeginTransactionRequest, opts ...grpc.CallOption) (*sppb.Transaction, error)
BeginTransaction is a placeholder for SpannerClient.BeginTransaction.
func (*MockCloudSpannerClient) CheckActionsConsumed ¶ added in v0.17.0
func (m *MockCloudSpannerClient) CheckActionsConsumed()
CheckActionsConsumed checks that all actions have been consumed.
func (*MockCloudSpannerClient) Commit ¶
func (m *MockCloudSpannerClient) Commit(c context.Context, r *sppb.CommitRequest, opts ...grpc.CallOption) (*sppb.CommitResponse, error)
Commit is a placeholder for SpannerClient.Commit.
func (*MockCloudSpannerClient) CreateSession ¶
func (m *MockCloudSpannerClient) CreateSession(c context.Context, r *sppb.CreateSessionRequest, opts ...grpc.CallOption) (*sppb.Session, error)
CreateSession is a placeholder for SpannerClient.CreateSession.
func (*MockCloudSpannerClient) DeleteSession ¶
func (m *MockCloudSpannerClient) DeleteSession(c context.Context, r *sppb.DeleteSessionRequest, opts ...grpc.CallOption) (*empty.Empty, error)
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) ExecuteStreamingSql ¶
func (m *MockCloudSpannerClient) ExecuteStreamingSql(c context.Context, r *sppb.ExecuteSqlRequest, opts ...grpc.CallOption) (sppb.Spanner_ExecuteStreamingSqlClient, error)
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 ¶
func (m *MockCloudSpannerClient) GetSession(c context.Context, r *sppb.GetSessionRequest, opts ...grpc.CallOption) (*sppb.Session, error)
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 calls to method 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) PartitionQuery ¶ added in v0.20.0
func (m *MockCloudSpannerClient) PartitionQuery(ctx context.Context, r *sppb.PartitionQueryRequest, opts ...grpc.CallOption) (*sppb.PartitionResponse, error)
PartitionQuery is a placeholder for SpannerServer.PartitionQuery.
func (*MockCloudSpannerClient) PartitionRead ¶ added in v0.20.0
func (m *MockCloudSpannerClient) PartitionRead(ctx context.Context, r *sppb.PartitionReadRequest, opts ...grpc.CallOption) (*sppb.PartitionResponse, error)
PartitionRead is a placeholder for SpannerServer.PartitionRead.
func (*MockCloudSpannerClient) Rollback ¶
func (m *MockCloudSpannerClient) Rollback(c context.Context, r *sppb.RollbackRequest, opts ...grpc.CallOption) (*empty.Empty, error)
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 ¶
func (m *MockCloudSpannerClient) StreamingRead(c context.Context, r *sppb.ReadRequest, opts ...grpc.CallOption) (sppb.Spanner_StreamingReadClient, error)
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