rpcmock

package
v0.39.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package rpcmock contains RPC mocking utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Handle(id int64, body bin.Encoder) (bin.Encoder, error)
}

Handler is a RPC call handler.

type HandlerFunc

type HandlerFunc func(id int64, body bin.Encoder) (bin.Encoder, error)

HandlerFunc is a function adapter for Handler.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(id int64, body bin.Encoder) (bin.Encoder, error)

Handle implements Handler.

type Mock

type Mock struct {
	*require.Assertions
	// contains filtered or unexported fields
}

Mock is a mock tg.Invoker.

func NewMock

func NewMock(testingT TestingT, assert *require.Assertions) *Mock

NewMock creates new Mock.

func (*Mock) AllWereMet

func (i *Mock) AllWereMet() bool

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 added in v0.26.0

func (i *Mock) ExpectFunc(fn func(b bin.Encoder)) *RequestBuilder

ExpectFunc creates builder of new expected call with given input checker.

func (*Mock) Handler

func (i *Mock) Handler() HandlerFunc

Handler returns HandlerFunc of Mock.

func (*Mock) InvokeRaw added in v0.26.0

func (i *Mock) InvokeRaw(ctx context.Context, input bin.Encoder, output bin.Decoder) error

InvokeRaw implements tg.Invoker.

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 added in v0.26.0

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 added in v0.26.0

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.

type TestingT

type TestingT interface {
	Cleanup(cb func())
}

TestingT is simplified *testing.T interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL