Documentation ¶
Index ¶
- Variables
- func WithSDK(t *testing.T, f func(*testing.T, *api.VK, *TestCase))
- type Expectation
- func (e *Expectation) Fails(fails bool) *Expectation
- func (e Expectation) Match(method string, params ...api.Params) (bool, api.Response, error)
- func (e *Expectation) Returns(response api.Response) *Expectation
- func (e *Expectation) ReturnsBytes(data []byte) *Expectation
- func (e *Expectation) ReturnsBytesF(f func() []byte) *Expectation
- func (e *Expectation) ReturnsF(f func() api.Response) *Expectation
- func (e *Expectation) ReturnsJSON(v interface{}) *Expectation
- func (e *Expectation) ReturnsJSONF(f func() interface{}) *Expectation
- func (e *Expectation) WithError(message string) *Expectation
- func (e *Expectation) WithParams(params api.Params) *Expectation
- func (e *Expectation) WithParamsF(f func() api.Params) *Expectation
- type Expectations
- type TestCase
Constants ¶
This section is empty.
Variables ¶
var ErrNotExpected = fmt.Errorf("call is not expected")
ErrNotExpected is expectation error.
Functions ¶
Types ¶
type Expectation ¶
type Expectation struct { Method string Params api.Params Response api.Response ErrorResponse bool ErrorMessage string }
Expectation is VK API call expectation.
func NewExpectation ¶
func NewExpectation(method string) *Expectation
NewExpectation creates new Expectation.
func (*Expectation) Fails ¶
func (e *Expectation) Fails(fails bool) *Expectation
Fails marks API result as failed.
func (*Expectation) Returns ¶
func (e *Expectation) Returns(response api.Response) *Expectation
Returns sets API call result.
func (*Expectation) ReturnsBytes ¶
func (e *Expectation) ReturnsBytes(data []byte) *Expectation
ReturnsBytes sets API call result.
func (*Expectation) ReturnsBytesF ¶
func (e *Expectation) ReturnsBytesF(f func() []byte) *Expectation
ReturnsBytesF sets API call result using function.
func (*Expectation) ReturnsF ¶
func (e *Expectation) ReturnsF(f func() api.Response) *Expectation
ReturnsF sets API call result using function.
func (*Expectation) ReturnsJSON ¶
func (e *Expectation) ReturnsJSON(v interface{}) *Expectation
ReturnsJSON sets API call result.
func (*Expectation) ReturnsJSONF ¶
func (e *Expectation) ReturnsJSONF(f func() interface{}) *Expectation
ReturnsJSONF sets API call result using function.
func (*Expectation) WithError ¶
func (e *Expectation) WithError(message string) *Expectation
WithError sets API call error. Calls Fails(true).
func (*Expectation) WithParams ¶
func (e *Expectation) WithParams(params api.Params) *Expectation
WithParams sets expected params. If API call contains unexpected params, it wouldn't fail.
func (*Expectation) WithParamsF ¶
func (e *Expectation) WithParamsF(f func() api.Params) *Expectation
WithParamsF sets expected params using function. If API call contains unexpected params, it wouldn't fail.
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 DefaultResponse api.Response // contains filtered or unexported fields }
TestCase is VK SDK testcase.
func (*TestCase) AllowNotExpected ¶
func (test *TestCase) AllowNotExpected()
AllowNotExpected allows not expected calls.
func (*TestCase) ExpectCall ¶
func (test *TestCase) ExpectCall(method string) *Expectation
ExpectCall adds call expectation.
func (*TestCase) ExpectationsError ¶ added in v2.0.1
ExpectationsError returns error if not all call expectation were met.
func (*TestCase) ExpectationsWereMet ¶
ExpectationsWereMet checks that all call expectation were met. Calls T.Error(err).