Documentation ¶
Overview ¶
Package tgmock implements mock for tg.Invoker.
Index ¶
- type Handler
- type HandlerFunc
- type Invoker
- type Mock
- func (i *Mock) AllWereMet() bool
- func (i *Mock) Expect() *RequestBuilder
- func (i *Mock) ExpectCall(body bin.Encoder) *RequestBuilder
- func (i *Mock) ExpectFunc(fn func(b bin.Encoder)) *RequestBuilder
- func (i *Mock) Handler() HandlerFunc
- func (i *Mock) Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error
- type Option
- type RequestBuilder
- func (b *RequestBuilder) N(times int) *RequestBuilder
- func (b *RequestBuilder) ThenErr(err error) *Mock
- func (b *RequestBuilder) ThenFalse() *Mock
- func (b *RequestBuilder) ThenFlood(arg int) *Mock
- func (b *RequestBuilder) ThenMigrate(typ string, arg int) *Mock
- func (b *RequestBuilder) ThenRPCErr(err *tgerr.Error) *Mock
- func (b *RequestBuilder) ThenResult(body bin.Encoder) *Mock
- func (b *RequestBuilder) ThenTrue() *Mock
- func (b *RequestBuilder) ThenUnregistered() *Mock
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
HandlerFunc is a function adapter for Handler.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock for tg.Invoker with testify/require support.
func NewRequire ¶ added in v0.43.0
NewRequire creates new Mock with "require" assertions.
func (*Mock) AllWereMet ¶
AllWereMet returns true if all expected calls happened.
func (*Mock) Expect ¶
func (i *Mock) Expect() *RequestBuilder
Expect creates builder of new expected call.
func (*Mock) ExpectCall ¶
func (i *Mock) ExpectCall(body bin.Encoder) *RequestBuilder
ExpectCall creates builder of new expected call with given input.
func (*Mock) ExpectFunc ¶
func (i *Mock) ExpectFunc(fn func(b bin.Encoder)) *RequestBuilder
ExpectFunc creates builder of new expected call with given input checker.
type Option ¶ added in v0.43.0
type Option interface {
// contains filtered or unexported methods
}
Option configures Mock.
func WithRequire ¶ added in v0.43.0
func WithRequire() Option
WithRequire configures mock to use "require" assertions.
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
RequestBuilder is builder of expected RPC request.
func (*RequestBuilder) N ¶
func (b *RequestBuilder) N(times int) *RequestBuilder
N sets count of expected calls.
func (*RequestBuilder) ThenErr ¶
func (b *RequestBuilder) ThenErr(err error) *Mock
ThenErr adds call result to the end of call stack.
func (*RequestBuilder) ThenFalse ¶
func (b *RequestBuilder) ThenFalse() *Mock
ThenFalse adds call tg.BoolFalse result to the end of call stack.
func (*RequestBuilder) ThenFlood ¶
func (b *RequestBuilder) ThenFlood(arg int) *Mock
ThenFlood adds call result to the end of call stack.
func (*RequestBuilder) ThenMigrate ¶
func (b *RequestBuilder) ThenMigrate(typ string, arg int) *Mock
ThenMigrate adds call result to the end of call stack.
func (*RequestBuilder) ThenRPCErr ¶
func (b *RequestBuilder) ThenRPCErr(err *tgerr.Error) *Mock
ThenRPCErr adds call result to the end of call stack.
func (*RequestBuilder) ThenResult ¶
func (b *RequestBuilder) ThenResult(body bin.Encoder) *Mock
ThenResult adds call result to the end of call stack.
func (*RequestBuilder) ThenTrue ¶
func (b *RequestBuilder) ThenTrue() *Mock
ThenTrue adds call tg.BoolTrue result to the end of call stack.
func (*RequestBuilder) ThenUnregistered ¶
func (b *RequestBuilder) ThenUnregistered() *Mock
ThenUnregistered adds call result to the end of call stack.