testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExpected = fmt.Errorf("call is not expected")

Functions

func WithSDK

func WithSDK(t *testing.T, f func(*testing.T, *api.VK, *TestCase))

Types

type Expectation

type Expectation struct {
	Method        string
	Params        api.Params
	Response      api.Response
	ErrorResponse bool
	ErrorMessage  string
}

func NewExpectation

func NewExpectation(method string) *Expectation

func (*Expectation) Fails

func (e *Expectation) Fails(fails bool) *Expectation

func (Expectation) Match

func (e Expectation) Match(method string, params api.Params) (bool, api.Response, error)

func (*Expectation) Returns

func (e *Expectation) Returns(response api.Response) *Expectation

func (*Expectation) ReturnsBytes

func (e *Expectation) ReturnsBytes(data []byte) *Expectation

func (*Expectation) ReturnsBytesF

func (e *Expectation) ReturnsBytesF(f func() []byte) *Expectation

func (*Expectation) ReturnsF

func (e *Expectation) ReturnsF(f func() api.Response) *Expectation

func (*Expectation) ReturnsJSON

func (e *Expectation) ReturnsJSON(v interface{}) *Expectation

func (*Expectation) ReturnsJSONF

func (e *Expectation) ReturnsJSONF(f func() interface{}) *Expectation

func (*Expectation) WithError

func (e *Expectation) WithError(message string) *Expectation

func (*Expectation) WithParams

func (e *Expectation) WithParams(params api.Params) *Expectation

func (*Expectation) WithParamsF

func (e *Expectation) WithParamsF(f func() api.Params) *Expectation

type Expectations

type Expectations []*Expectation

func (*Expectations) Pop

func (stack *Expectations) Pop() (result *Expectation, ok bool)

func (*Expectations) Push

func (stack *Expectations) Push(element *Expectation)

type TestCase

type TestCase struct {
	Expectations Expectations
	T            *testing.T
}

func CreateSDK

func CreateSDK(t *testing.T) (*api.VK, *TestCase)

func NewTestCase

func NewTestCase(t *testing.T) *TestCase

func (*TestCase) ExpectCall

func (test *TestCase) ExpectCall(method string) *Expectation

func (*TestCase) ExpectationsWereMet

func (test *TestCase) ExpectationsWereMet() error

func (*TestCase) Handler

func (test *TestCase) Handler() sdkutil.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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