go: cloud.google.com/go/spanner/internal/testutil Index | Files

package testutil

import "cloud.google.com/go/spanner/internal/testutil"

Index

Package Files

mockclient.go mockserver.go

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},
                },
            },
        },
    }
)

func DecodeResumeToken Uses

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

DecodeResumeToken decodes a mock resume token into an uint64 integer.

func EncodeResumeToken Uses

func EncodeResumeToken(t uint64) []byte

EncodeResumeToken return mock resume token encoding for an uint64 integer.

type Action Uses

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

Action is a mocked RPC activity that MockCloudSpannerClient will take.

func NewAction Uses

func NewAction(m string, e error) Action

NewAction creates Action objects.

type MockCloudSpanner Uses

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 Uses

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

NewMockCloudSpanner creates a new MockCloudSpanner instance.

func (*MockCloudSpanner) AddMsg Uses

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

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

func (*MockCloudSpanner) Addr Uses

func (m *MockCloudSpanner) Addr() string

Addr returns the listening address of mock server.

func (*MockCloudSpanner) BeginTransaction Uses

func (m *MockCloudSpanner) BeginTransaction(c context.Context, r *sppb.BeginTransactionRequest) (*sppb.Transaction, error)

BeginTransaction is a placeholder for SpannerServer.BeginTransaction.

func (*MockCloudSpanner) Commit Uses

func (m *MockCloudSpanner) Commit(c context.Context, r *sppb.CommitRequest) (*sppb.CommitResponse, error)

Commit is a placeholder for SpannerServer.Commit.

func (*MockCloudSpanner) CreateSession Uses

func (m *MockCloudSpanner) CreateSession(c context.Context, r *sppb.CreateSessionRequest) (*sppb.Session, error)

CreateSession is a placeholder for SpannerServer.CreateSession.

func (*MockCloudSpanner) DeleteSession Uses

func (m *MockCloudSpanner) DeleteSession(c context.Context, r *sppb.DeleteSessionRequest) (*empty.Empty, error)

DeleteSession is a placeholder for SpannerServer.DeleteSession.

func (*MockCloudSpanner) Done Uses

func (m *MockCloudSpanner) Done()

Done signals an end to a mocked stream.

func (*MockCloudSpanner) ExecuteSql Uses

func (m *MockCloudSpanner) ExecuteSql(c context.Context, r *sppb.ExecuteSqlRequest) (*sppb.ResultSet, error)

ExecuteSql is a placeholder for SpannerServer.ExecuteSql.

func (*MockCloudSpanner) ExecuteStreamingSql Uses

func (m *MockCloudSpanner) ExecuteStreamingSql(r *sppb.ExecuteSqlRequest, s sppb.Spanner_ExecuteStreamingSqlServer) error

ExecuteStreamingSql is a mock implementation of SpannerServer.ExecuteStreamingSql.

func (*MockCloudSpanner) GetSession Uses

func (m *MockCloudSpanner) GetSession(c context.Context, r *sppb.GetSessionRequest) (*sppb.Session, error)

GetSession is a placeholder for SpannerServer.GetSession.

func (*MockCloudSpanner) Read Uses

func (m *MockCloudSpanner) Read(c context.Context, r *sppb.ReadRequest) (*sppb.ResultSet, error)

Read is a placeholder for SpannerServer.Read.

func (*MockCloudSpanner) Rollback Uses

func (m *MockCloudSpanner) Rollback(c context.Context, r *sppb.RollbackRequest) (*empty.Empty, error)

Rollback is a placeholder for SpannerServer.Rollback.

func (*MockCloudSpanner) Serve Uses

func (m *MockCloudSpanner) Serve()

Serve runs a MockCloudSpanner listening on a random localhost address.

func (*MockCloudSpanner) Stop Uses

func (m *MockCloudSpanner) Stop()

Stop terminates MockCloudSpanner and closes the serving port.

func (*MockCloudSpanner) StreamingRead Uses

func (m *MockCloudSpanner) StreamingRead(r *sppb.ReadRequest, s sppb.Spanner_StreamingReadServer) error

StreamingRead is a placeholder for SpannerServer.StreamingRead.

type MockCloudSpannerClient Uses

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

MockCloudSpannerClient is a mock implementation of sppb.SpannerClient.

func NewMockCloudSpannerClient Uses

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

NewMockCloudSpannerClient creates new MockCloudSpannerClient instance.

func (*MockCloudSpannerClient) BeginTransaction Uses

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) Commit Uses

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 Uses

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 Uses

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 Uses

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

DumpPings dumps the ping history.

func (*MockCloudSpannerClient) DumpSessions Uses

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

DumpSessions dumps the internal session table.

func (*MockCloudSpannerClient) ExecuteSql Uses

func (m *MockCloudSpannerClient) ExecuteSql(c context.Context, r *sppb.ExecuteSqlRequest, opts ...grpc.CallOption) (*sppb.ResultSet, error)

ExecuteSql is a placeholder for SpannerClient.ExecuteSql.

func (*MockCloudSpannerClient) ExecuteStreamingSql Uses

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) GetSession Uses

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 Uses

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 Uses

func (m *MockCloudSpannerClient) MakeNice()

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

func (*MockCloudSpannerClient) MakeStrict Uses

func (m *MockCloudSpannerClient) MakeStrict()

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

func (*MockCloudSpannerClient) Read Uses

func (m *MockCloudSpannerClient) Read(c context.Context, r *sppb.ReadRequest, opts ...grpc.CallOption) (*sppb.ResultSet, error)

Read is a placeholder for SpannerClient.Read.

func (*MockCloudSpannerClient) Rollback Uses

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 Uses

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

SetActions sets the new set of expected actions to MockCloudSpannerClient.

func (*MockCloudSpannerClient) StreamingRead Uses

func (m *MockCloudSpannerClient) StreamingRead(c context.Context, r *sppb.ReadRequest, opts ...grpc.CallOption) (sppb.Spanner_StreamingReadClient, error)

StreamingRead is a placeholder for SpannerClient.StreamingRead.

type MockCtlMsg Uses

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

Package testutil imports 16 packages (graph). Updated 2017-05-27. Refresh now. Tools for package owners.