Documentation ¶
Overview ¶
Package test provides various testing utilities.
Index ¶
- Constants
- Variables
- func AssertClusterAuthRequest(ctx context.Context, reqCh <-chan ClusterAuthRequest, resp grpc.CallOption) bool
- func AssertClusterGetPeerRequest(ctx context.Context, reqCh <-chan ClusterGetPeerRequest, ...) bool
- func AssertClusterGetPeerRequestSequence(ctx context.Context, reqCh <-chan ClusterGetPeerRequest, ...) bool
- func AssertEventPubSubPublishRequest(ctx context.Context, reqCh <-chan EventPubSubPublishRequest, ...) bool
- func AssertEventPubSubPublishRequests(ctx context.Context, reqCh <-chan EventPubSubPublishRequest, n int, ...) bool
- func AssertListRightsRequest(ctx context.Context, reqCh <-chan ApplicationAccessListRightsRequest, ...) bool
- func ClusterJoinNilFunc() error
- func CollectEvents(f func()) []events.Event
- func Context() context.Context
- func ContextWithT(ctx context.Context, t *testing.T) context.Context
- func DiffEqual(x, y interface{}) bool
- func EventDefinitionDataClosureEqual(a, b events.DefinitionDataClosure) bool
- func EventEqual(a, b events.Event) bool
- func GetLogger(t testing.TB) log.Stack
- func IsProperSubsetOfElements(eq interface{}, sub, super interface{}) bool
- func IsSubsetOfElements(eq interface{}, sub, super interface{}) bool
- func MakeApplicationAccessListRightsChFunc(reqCh chan<- ApplicationAccessListRightsRequest) func(context.Context, *ttnpb.ApplicationIdentifiers) (*ttnpb.Rights, error)
- func MakeClusterAuthChFunc(reqCh chan<- ClusterAuthRequest) func() grpc.CallOption
- func MakeClusterGetPeerChFunc(reqCh chan<- ClusterGetPeerRequest) ...
- func MakeClusterJoinChFunc(reqCh chan<- ClusterJoinRequest) func() error
- func MakeEventPubSubPublishChFunc(reqCh chan<- EventPubSubPublishRequest) func(events.Event)
- func MapKeys(m interface{}) []interface{}
- func Must(v interface{}, err error) interface{}
- func MustMultiple(vs ...interface{}) []interface{}
- func MustTFromContext(ctx context.Context) *testing.T
- func NewRedis(t testing.TB, namespace ...string) (*ttnredis.Client, func())
- func RedirectEvents(ch chan events.Event) func()
- func SameElements(eq interface{}, xs, ys interface{}) bool
- func SetDefaultEventsPubSub(ps events.PubSub) func()
- func StringEqual(x, y string) bool
- func TFromContext(ctx context.Context) (*testing.T, bool)
- func WaitContext(ctx context.Context, f func()) (ok bool)
- func WaitDeadline(t time.Time, f func()) (ok bool)
- func WaitEvent(ctx context.Context, ch chan events.Event, name string) bool
- func WaitTimeout(d time.Duration, f func()) (ok bool)
- type ApplicationAccessListRightsRequest
- type ApplicationAccessListRightsResponse
- type ClusterAuthRequest
- type ClusterGetPeerRequest
- type ClusterGetPeerResponse
- type ClusterJoinRequest
- type EventPubSubPublishRequest
- type MockApplicationAccessServer
- func (m MockApplicationAccessServer) CreateAPIKey(ctx context.Context, req *ttnpb.CreateApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
- func (m MockApplicationAccessServer) GetAPIKey(ctx context.Context, req *ttnpb.GetApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
- func (m MockApplicationAccessServer) GetCollaborator(ctx context.Context, req *ttnpb.GetApplicationCollaboratorRequest) (*ttnpb.GetCollaboratorResponse, error)
- func (m MockApplicationAccessServer) ListAPIKeys(ctx context.Context, req *ttnpb.ListApplicationAPIKeysRequest) (*ttnpb.APIKeys, error)
- func (m MockApplicationAccessServer) ListCollaborators(ctx context.Context, req *ttnpb.ListApplicationCollaboratorsRequest) (*ttnpb.Collaborators, error)
- func (m MockApplicationAccessServer) ListRights(ctx context.Context, req *ttnpb.ApplicationIdentifiers) (*ttnpb.Rights, error)
- func (m MockApplicationAccessServer) SetCollaborator(ctx context.Context, req *ttnpb.SetApplicationCollaboratorRequest) (*pbtypes.Empty, error)
- func (m MockApplicationAccessServer) UpdateAPIKey(ctx context.Context, req *ttnpb.UpdateApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
- type MockClientStream
- type MockClock
- type MockCluster
- func (m MockCluster) Auth() grpc.CallOption
- func (m MockCluster) ClaimIDs(ctx context.Context, ids ttnpb.Identifiers) error
- func (m MockCluster) GetPeer(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) (cluster.Peer, error)
- func (m MockCluster) GetPeerConn(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) (*grpc.ClientConn, error)
- func (m MockCluster) GetPeers(ctx context.Context, role ttnpb.ClusterRole) ([]cluster.Peer, error)
- func (m MockCluster) Join() error
- func (m MockCluster) Leave() error
- func (m MockCluster) TLS() bool
- func (m MockCluster) UnclaimIDs(ctx context.Context, ids ttnpb.Identifiers) error
- func (m MockCluster) WithVerifiedSource(ctx context.Context) context.Context
- type MockEventPubSub
- type MockPeer
- type MockProtoMarshaler
- type MockProtoMessage
- type MockProtoMessageMarshalUnmarshaler
- type MockProtoUnmarshaler
- type MockServerStream
- type MockServerTransportStream
- type MockStream
- type Ranger
Constants ¶
const ( // EUFrequencyPlanID is a European frequency plan for testing. EUFrequencyPlanID = "EU_863_870" // KRFrequencyPlanID is a Korean frequency plan for testing. KRFrequencyPlanID = "KR_920_923" // USFrequencyPlanID is a American frequency plan for testing. USFrequencyPlanID = "US_902_928_FSB_2" // ASAUFrequencyPlanID is an AS923 for Australia frequency plan for testing. ASAUFrequencyPlanID = "AS_923_925_AU" // ExampleFrequencyPlanID is an example frequency plan. ExampleFrequencyPlanID = "EXAMPLE" )
Variables ¶
var DefaultContext = context.Background()
DefaultContext is the default context.
var Delay = time.Millisecond * func() time.Duration { env := os.Getenv("TEST_SLOWDOWN") if env == "" { return 1 } v, err := strconv.Atoi(env) if err != nil { return 1 } return time.Duration(v) }()
Delay is the value, which can be used to slowdown the execution of time-dependent tests. You can assume, that most function calls will return in at most Delay time. It can(and should) be used to construct other time variables used in testing. Value may vary from machine to machine and can be overridden by TEST_SLOWDOWN environment variable.
var FrequencyPlansFetcher = fetch.NewMemFetcher(map[string][]byte{ "frequency-plans.yml": []byte(frequencyPlansDescription), "EU_863_870.yml": []byte(euFrequencyPlan), "KR_920_923.yml": []byte(krFrequencyPlan), "US_902_928_FSB_2.yml": []byte(usFrequencyPlan), "AS_923_925_AU.yml": []byte(asAUFrequencyPlan), "EXAMPLE.yml": []byte(exampleFrequencyPlan), })
FrequencyPlansFetcher fetches frequency plans from memory.
var Randy = randutil.NewLockedRand(rand.NewSource(42))
Randy is global rand, which is safe for concurrent use.
Functions ¶
func AssertClusterAuthRequest ¶
func AssertClusterAuthRequest(ctx context.Context, reqCh <-chan ClusterAuthRequest, resp grpc.CallOption) bool
func AssertClusterGetPeerRequest ¶
func AssertClusterGetPeerRequest(ctx context.Context, reqCh <-chan ClusterGetPeerRequest, assert func(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) bool, resp ClusterGetPeerResponse) bool
func AssertClusterGetPeerRequestSequence ¶
func AssertClusterGetPeerRequestSequence(ctx context.Context, reqCh <-chan ClusterGetPeerRequest, peers []ClusterGetPeerResponse, assertions ...func(context.Context, ttnpb.ClusterRole, ttnpb.Identifiers) bool) bool
func AssertListRightsRequest ¶
func ClusterJoinNilFunc ¶
func ClusterJoinNilFunc() error
func CollectEvents ¶
CollectEvents collects events published by f.
func ContextWithT ¶
ContextWithT saves the testing.T in the context.
func DiffEqual ¶
func DiffEqual(x, y interface{}) bool
DiffEqual returns true iff pretty.Diff of x and y is empty and false otherwise.
func EventDefinitionDataClosureEqual ¶
func EventDefinitionDataClosureEqual(a, b events.DefinitionDataClosure) bool
func EventEqual ¶
func IsProperSubsetOfElements ¶
func IsProperSubsetOfElements(eq interface{}, sub, super interface{}) bool
IsProperSubsetOfElements is like IsSubsetOfElements, but checks for proper subset.
func IsSubsetOfElements ¶
func IsSubsetOfElements(eq interface{}, sub, super interface{}) bool
IsSubsetOfElements returns true iff a multiset sub represents a subset of multiset super under equality given by eq. Signature of eq must be func(A, B) bool, where A, B are types, which elements of sub and super can be assigned to respectively. It panics if either sub or super is not one of: 1. string, slice, array or map kind 2. value, which implements Ranger interface(e.g. sync.Map) NOTE: Map key values are not taken into account.
func MakeApplicationAccessListRightsChFunc ¶
func MakeApplicationAccessListRightsChFunc(reqCh chan<- ApplicationAccessListRightsRequest) func(context.Context, *ttnpb.ApplicationIdentifiers) (*ttnpb.Rights, error)
func MakeClusterAuthChFunc ¶
func MakeClusterAuthChFunc(reqCh chan<- ClusterAuthRequest) func() grpc.CallOption
func MakeClusterGetPeerChFunc ¶
func MakeClusterGetPeerChFunc(reqCh chan<- ClusterGetPeerRequest) func(context.Context, ttnpb.ClusterRole, ttnpb.Identifiers) (cluster.Peer, error)
func MakeClusterJoinChFunc ¶
func MakeClusterJoinChFunc(reqCh chan<- ClusterJoinRequest) func() error
func MakeEventPubSubPublishChFunc ¶
func MakeEventPubSubPublishChFunc(reqCh chan<- EventPubSubPublishRequest) func(events.Event)
func MapKeys ¶
func MapKeys(m interface{}) []interface{}
MapKeys returns the keys of a map as a slice.
func Must ¶
func Must(v interface{}, err error) interface{}
Must returns v if err is nil and panics otherwise.
func MustMultiple ¶
func MustMultiple(vs ...interface{}) []interface{}
MustMultiple is like Must, but operates on arbitrary amount of values. It assumes that last value in vs is an error. It panics if len(vs) == 0.
func MustTFromContext ¶
MustTFromContext returns the test state from the context, and panics if it was not saved in the context.
func NewRedis ¶
NewRedis returns a new namespaced *redis.Client ready to use and a flush function, which should be called after the client is not needed anymore to clean the namespace. NewRedis respects TEST_REDIS, REDIS_ADDRESS and REDIS_DB environment variables. Client returned logs commands executed.
func RedirectEvents ¶
RedirectEvents redirects the published events to the provided channel until the returned function is called.
func SameElements ¶
func SameElements(eq interface{}, xs, ys interface{}) bool
SameElements returns true iff IsSubsetOfElements(eq, xs, ys) returns true and IsSubsetOfElements(eq, ys, xs) returns true and false otherwise.
func SetDefaultEventsPubSub ¶
SetDefaultEventsPubSub calls events.SetDefaultPubSub and returns a function that can be used to undo the action. Following calls to SetDefaultEventsPubSub will block until undo function is called.
func StringEqual ¶
StringEqual returns true iff strings x and y are equal and false otherwise.
func TFromContext ¶
TFromContext returns the testing.T saved using ContextWithT from the context.
func WaitContext ¶
WaitContext returns true if f returns before <-ctx.Done() or false otherwise. An example of a f, for which this is useful would be Wait method of sync.WaitGroup. Note, this function leaks a goroutine if f never returns.
func WaitDeadline ¶
WaitDeadline returns WaitTimeout(time.Until(t), f).
func WaitTimeout ¶
WaitTimeout returns true if f returns after at most d or false otherwise. An example of a f, for which this is useful would be Wait method of sync.WaitGroup. Note, this function leaks a goroutine if f never returns.
Types ¶
type ApplicationAccessListRightsRequest ¶
type ApplicationAccessListRightsRequest struct { Context context.Context Message *ttnpb.ApplicationIdentifiers Response chan<- ApplicationAccessListRightsResponse }
type ClusterAuthRequest ¶
type ClusterAuthRequest struct {
Response chan<- grpc.CallOption
}
type ClusterGetPeerRequest ¶
type ClusterGetPeerRequest struct { Context context.Context Role ttnpb.ClusterRole Identifiers ttnpb.Identifiers Response chan<- ClusterGetPeerResponse }
type ClusterGetPeerResponse ¶
type ClusterJoinRequest ¶
type ClusterJoinRequest struct {
Response chan<- error
}
type MockApplicationAccessServer ¶
type MockApplicationAccessServer struct { CreateAPIKeyFunc func(context.Context, *ttnpb.CreateApplicationAPIKeyRequest) (*ttnpb.APIKey, error) GetAPIKeyFunc func(context.Context, *ttnpb.GetApplicationAPIKeyRequest) (*ttnpb.APIKey, error) ListAPIKeysFunc func(context.Context, *ttnpb.ListApplicationAPIKeysRequest) (*ttnpb.APIKeys, error) ListCollaboratorsFunc func(context.Context, *ttnpb.ListApplicationCollaboratorsRequest) (*ttnpb.Collaborators, error) ListRightsFunc func(context.Context, *ttnpb.ApplicationIdentifiers) (*ttnpb.Rights, error) GetCollaboratorFunc func(context.Context, *ttnpb.GetApplicationCollaboratorRequest) (*ttnpb.GetCollaboratorResponse, error) SetCollaboratorFunc func(context.Context, *ttnpb.SetApplicationCollaboratorRequest) (*pbtypes.Empty, error) UpdateAPIKeyFunc func(context.Context, *ttnpb.UpdateApplicationAPIKeyRequest) (*ttnpb.APIKey, error) }
MockApplicationAccessServer is a mock ttnpb.ApplicationAccessServer used for testing.
func (MockApplicationAccessServer) CreateAPIKey ¶
func (m MockApplicationAccessServer) CreateAPIKey(ctx context.Context, req *ttnpb.CreateApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
CreateAPIKey calls CreateAPIKeyFunc if set and panics otherwise.
func (MockApplicationAccessServer) GetAPIKey ¶
func (m MockApplicationAccessServer) GetAPIKey(ctx context.Context, req *ttnpb.GetApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
GetAPIKey calls GetAPIKeyFunc if set and panics otherwise.
func (MockApplicationAccessServer) GetCollaborator ¶
func (m MockApplicationAccessServer) GetCollaborator(ctx context.Context, req *ttnpb.GetApplicationCollaboratorRequest) (*ttnpb.GetCollaboratorResponse, error)
GetCollaborator calls GetCollaboratorFunc if set and panics otherwise.
func (MockApplicationAccessServer) ListAPIKeys ¶
func (m MockApplicationAccessServer) ListAPIKeys(ctx context.Context, req *ttnpb.ListApplicationAPIKeysRequest) (*ttnpb.APIKeys, error)
ListAPIKeys calls ListAPIKeysFunc if set and panics otherwise.
func (MockApplicationAccessServer) ListCollaborators ¶
func (m MockApplicationAccessServer) ListCollaborators(ctx context.Context, req *ttnpb.ListApplicationCollaboratorsRequest) (*ttnpb.Collaborators, error)
ListCollaborators calls ListCollaboratorsFunc if set and panics otherwise.
func (MockApplicationAccessServer) ListRights ¶
func (m MockApplicationAccessServer) ListRights(ctx context.Context, req *ttnpb.ApplicationIdentifiers) (*ttnpb.Rights, error)
ListRights calls ListRightsFunc if set and panics otherwise.
func (MockApplicationAccessServer) SetCollaborator ¶
func (m MockApplicationAccessServer) SetCollaborator(ctx context.Context, req *ttnpb.SetApplicationCollaboratorRequest) (*pbtypes.Empty, error)
SetCollaborator calls SetCollaboratorFunc if set and panics otherwise.
func (MockApplicationAccessServer) UpdateAPIKey ¶
func (m MockApplicationAccessServer) UpdateAPIKey(ctx context.Context, req *ttnpb.UpdateApplicationAPIKeyRequest) (*ttnpb.APIKey, error)
UpdateAPIKey calls UpdateAPIKeyFunc if set and panics otherwise.
type MockClientStream ¶
type MockClientStream struct { *MockStream HeaderFunc func() (metadata.MD, error) TrailerFunc func() metadata.MD CloseSendFunc func() error }
MockClientStream is a mock grpc.ClientStream.
func (MockClientStream) CloseSend ¶
func (m MockClientStream) CloseSend() error
CloseSend calls CloseSendFunc if set and panics otherwise.
func (MockClientStream) Header ¶
func (m MockClientStream) Header() (metadata.MD, error)
Header calls HeaderFunc if set and panics otherwise.
func (MockClientStream) Trailer ¶
func (m MockClientStream) Trailer() metadata.MD
Trailer calls TrailerFunc if set and panics otherwise.
type MockClock ¶
type MockClock struct {
// contains filtered or unexported fields
}
MockClock is used to mock time package functionality.
type MockCluster ¶
type MockCluster struct { JoinFunc func() error LeaveFunc func() error GetPeersFunc func(ctx context.Context, role ttnpb.ClusterRole) ([]cluster.Peer, error) GetPeerFunc func(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) (cluster.Peer, error) ClaimIDsFunc func(ctx context.Context, ids ttnpb.Identifiers) error UnclaimIDsFunc func(ctx context.Context, ids ttnpb.Identifiers) error TLSFunc func() bool AuthFunc func() grpc.CallOption WithVerifiedSourceFunc func(ctx context.Context) context.Context }
MockCluster is a mock cluster.Cluster used for testing.
func (MockCluster) Auth ¶
func (m MockCluster) Auth() grpc.CallOption
Auth calls AuthFunc if set and panics otherwise.
func (MockCluster) ClaimIDs ¶
func (m MockCluster) ClaimIDs(ctx context.Context, ids ttnpb.Identifiers) error
ClaimIDs calls ClaimIDsFunc if set and panics otherwise.
func (MockCluster) GetPeer ¶
func (m MockCluster) GetPeer(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) (cluster.Peer, error)
GetPeer calls GetPeerFunc if set and panics otherwise.
func (MockCluster) GetPeerConn ¶
func (m MockCluster) GetPeerConn(ctx context.Context, role ttnpb.ClusterRole, ids ttnpb.Identifiers) (*grpc.ClientConn, error)
GetPeerConn calls GetPeer and then Conn.
func (MockCluster) GetPeers ¶
func (m MockCluster) GetPeers(ctx context.Context, role ttnpb.ClusterRole) ([]cluster.Peer, error)
GetPeers calls GetPeersFunc if set and panics otherwise.
func (MockCluster) Join ¶
func (m MockCluster) Join() error
Join calls JoinFunc if set and panics otherwise.
func (MockCluster) Leave ¶
func (m MockCluster) Leave() error
Leave calls LeaveFunc if set and panics otherwise.
func (MockCluster) TLS ¶
func (m MockCluster) TLS() bool
TLS calls TLSFunc if set and panics otherwise.
func (MockCluster) UnclaimIDs ¶
func (m MockCluster) UnclaimIDs(ctx context.Context, ids ttnpb.Identifiers) error
UnclaimIDs calls UnclaimIDsFunc if set and panics otherwise.
func (MockCluster) WithVerifiedSource ¶
func (m MockCluster) WithVerifiedSource(ctx context.Context) context.Context
WithVerifiedSource calls WithVerifiedSourceFunc if set and panics otherwise.
type MockEventPubSub ¶
type MockEventPubSub struct { PublishFunc func(events.Event) SubscribeFunc func(string, events.Handler) error UnsubscribeFunc func(string, events.Handler) }
func (MockEventPubSub) Publish ¶
func (m MockEventPubSub) Publish(ev events.Event)
Publish calls PublishFunc if set and panics otherwise.
func (MockEventPubSub) Subscribe ¶
func (m MockEventPubSub) Subscribe(name string, hdl events.Handler) error
Subscribe calls SubscribeFunc if set and panics otherwise.
func (MockEventPubSub) Unsubscribe ¶
func (m MockEventPubSub) Unsubscribe(name string, hdl events.Handler)
Unsubscribe calls UnsubscribeFunc if set and panics otherwise.
type MockPeer ¶
type MockPeer struct { NameFunc func() string ConnFunc func() (*grpc.ClientConn, error) HasRoleFunc func(ttnpb.ClusterRole) bool RolesFunc func() []ttnpb.ClusterRole TagsFunc func() map[string]string }
MockPeer is a mock cluster.Peer used for testing.
func NewGRPCServerPeer ¶
func NewGRPCServerPeer(ctx context.Context, srv interface{}, registrators ...interface{}) (*MockPeer, error)
NewGRPCServerPeer creates a new MockPeer with ConnFunc, which always returns the same loopback connection to the server itself. srv is the implementation of the gRPC interface. registrators represents a slice of functions, which register the gRPC interface implementation at a gRPC server.
func (MockPeer) Conn ¶
func (m MockPeer) Conn() (*grpc.ClientConn, error)
Conn calls ConnFunc if set and panics otherwise.
func (MockPeer) HasRole ¶
func (m MockPeer) HasRole(r ttnpb.ClusterRole) bool
HasRole calls HasRoleFunc if set and panics otherwise.
func (MockPeer) Roles ¶
func (m MockPeer) Roles() []ttnpb.ClusterRole
Roles calls RolesFunc if set and panics otherwise.
type MockProtoMarshaler ¶
MockProtoMarshaler is a mock proto.Marshaler used for testing.
func (MockProtoMarshaler) Marshal ¶
func (m MockProtoMarshaler) Marshal() ([]byte, error)
Marshal calls MarshalFunc if set and panics otherwise.
type MockProtoMessage ¶
type MockProtoMessage struct { ResetFunc func() StringFunc func() string ProtoMessageFunc func() }
MockProtoMessage is a mock proto.Message used for testing.
func (MockProtoMessage) ProtoMessage ¶
func (m MockProtoMessage) ProtoMessage()
ProtoMessage calls ProtoMessageFunc if set and panics otherwise.
func (MockProtoMessage) Reset ¶
func (m MockProtoMessage) Reset()
Reset calls ResetFunc if set and panics otherwise.
func (MockProtoMessage) String ¶
func (m MockProtoMessage) String() string
String calls StringFunc if set and panics otherwise.
type MockProtoMessageMarshalUnmarshaler ¶
type MockProtoMessageMarshalUnmarshaler struct { MockProtoMessage MockProtoMarshaler MockProtoUnmarshaler }
MockProtoMessageMarshalUnmarshaler is a mock proto.Message, proto.Marshaler and proto.Unmarshaler used for testing.
type MockProtoUnmarshaler ¶
MockProtoUnmarshaler is a mock proto.Unmarshaler used for testing.
func (MockProtoUnmarshaler) Unmarshal ¶
func (m MockProtoUnmarshaler) Unmarshal(b []byte) error
Unmarshal calls UnmarshalFunc if set and panics otherwise.
type MockServerStream ¶
type MockServerStream struct { *MockStream SetHeaderFunc func(md metadata.MD) error SendHeaderFunc func(md metadata.MD) error SetTrailerFunc func(md metadata.MD) }
MockServerStream is a mock grpc.ServerStream.
func (MockServerStream) SendHeader ¶
func (m MockServerStream) SendHeader(md metadata.MD) error
SendHeader calls SendHeaderFunc if set and panics otherwise.
func (MockServerStream) SetHeader ¶
func (m MockServerStream) SetHeader(md metadata.MD) error
SetHeader calls SetHeaderFunc if set and panics otherwise.
func (MockServerStream) SetTrailer ¶
func (m MockServerStream) SetTrailer(md metadata.MD)
SetTrailer calls SetTrailerFunc if set and panics otherwise.
type MockServerTransportStream ¶
type MockServerTransportStream struct { *MockServerStream MethodFunc func() string SetTrailerFunc func(metadata.MD) error }
MockServerTransportStream is a mock grpc.ServerTransportStream.
func (MockServerTransportStream) Method ¶
func (m MockServerTransportStream) Method() string
Method calls MethodFunc if set and panics otherwise.
func (MockServerTransportStream) SetTrailer ¶
func (m MockServerTransportStream) SetTrailer(md metadata.MD) error
SetTrailer calls SetTrailerFunc if set and panics otherwise.
type MockStream ¶
type MockStream struct { ContextFunc func() context.Context SendMsgFunc func(m interface{}) error RecvMsgFunc func(m interface{}) error }
MockStream is a mock grpc.Stream.
func (MockStream) Context ¶
func (m MockStream) Context() context.Context
Context calls ContextFunc if set and panics otherwise.
func (MockStream) RecvMsg ¶
func (m MockStream) RecvMsg(msg interface{}) error
RecvMsg calls RecvMsgFunc if set and panics otherwise.
func (MockStream) SendMsg ¶
func (m MockStream) SendMsg(msg interface{}) error
SendMsg calls SendMsgFunc if set and panics otherwise.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package assertions contains custom assertions compatible with github.com/smartystreets/assertions.
|
Package assertions contains custom assertions compatible with github.com/smartystreets/assertions. |
should
Package should wraps assertions in github.com/smartystreets/assertions and util/test/assertions.
|
Package should wraps assertions in github.com/smartystreets/assertions and util/test/assertions. |