Documentation ¶
Index ¶
- func MatchAny[I protomsg](actual I) int
- func PB[T protomsg](t T) T
- func PBEq[T protomsg](t *testing.T, expected, actual T, msgAndArgs ...any)
- func UnaryMethod[S any, I, O protomsg](m func(S, context.Context, I) (O, error)) string
- type MatchFunc
- type Mock
- type Reg
- type Stub
- func NewErrStub[I, O protomsg](method string, request I, err error) Stub
- func NewMatchErrStub[I, O protomsg](method string, requestMatchFunc MatchFunc[I], err error) Stub
- func NewMatchStub[I, O protomsg](method string, requestMatchFunc MatchFunc[I], response O) Stub
- func NewStub[I, O protomsg](method string, request I, response O) Stub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchAny ¶
func MatchAny[I protomsg](actual I) int
MatchAny is a special matcher that matches any request.
func PB ¶
func PB[T protomsg](t T) T
PB prepares protobuf struct for comparison. It returns a copy of it's argument with all unexported fields set to zero values.
Types ¶
type MatchFunc ¶
type MatchFunc[I protomsg] func(actual I) int
MatchFunc is a function that matches stubs for request. Return value of zero means full match.
func NewDefaultMatchFunc ¶
func NewDefaultMatchFunc[I protomsg](expected I) MatchFunc[I]
NewDefaultMatchFunc returns default match function.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock server. Use New to instantiate.
func (*Mock) AddService ¶
AddService adds new service with stubs. First argument is mockaka.Register(pb.ServiceServer).
type Reg ¶
type Reg struct {
// contains filtered or unexported fields
}
Reg is a processed representation of RegisterServiceServer function generated by protoc.
type Stub ¶
type Stub interface { Times(n int) Stub Name(name string) Stub // contains filtered or unexported methods }
Stub contains request or matcher and corresponding response.
func NewErrStub ¶
NewErrStub creates new stub that will return an error. It will be used if request matches exactly. NewErrStub demands explicit type parameters.
func NewMatchErrStub ¶
NewMatchErrStub creates a new stub that will return an error. It uses provided MatchFunc for matching. NewMatchErrStub demands explicit type parameters.
func NewMatchStub ¶
NewMatchStub creates a new stub using provided MatchFunc.