mockassert

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Skip = &skip{}

Skip is a sentinel value which is skipped in a call instance asserter. This is useful when used to skip the leading "don't care" values such as leading context parameters.

Functions

func Called

func Called(t assert.TestingT, mockFn interface{}, msgAndArgs ...interface{}) bool

Called asserts that the mock function object was called at least once.

func CalledAtNWith

func CalledAtNWith(t assert.TestingT, mockFn interface{}, n int, asserter CallInstanceAsserter, msgAndArgs ...interface{}) bool

CalledAtNWith asserts that the mock function objects nth call was with a set of arguments matching the given call instance asserter.

func CalledN

func CalledN(t assert.TestingT, mockFn interface{}, n int, msgAndArgs ...interface{}) bool

CalledN asserts that the mock function object was called exactly n times.

func CalledNWith

func CalledNWith(t assert.TestingT, mockFn interface{}, n int, asserter CallInstanceAsserter, msgAndArgs ...interface{}) bool

CalledNWith asserts that the mock function object was called exactly n times with a set of arguments matching the given call instance asserter.

func CalledOnce

func CalledOnce(t assert.TestingT, mockFn interface{}, msgAndArgs ...interface{}) bool

CalledOnce asserts that the mock function object was called exactly once.

func CalledOnceWith

func CalledOnceWith(t assert.TestingT, mockFn interface{}, asserter CallInstanceAsserter, msgAndArgs ...interface{}) bool

CalledOnceWith asserts that the mock function object was called exactly once with a set of arguments matching the given call instance asserter.

func CalledWith

func CalledWith(t assert.TestingT, mockFn interface{}, asserter CallInstanceAsserter, msgAndArgs ...interface{}) bool

CalledWith asserts that the mock function object was called at least once with a set of arguments matching the given call instance asserter.

func NotCalled

func NotCalled(t assert.TestingT, mockFn interface{}, msgAndArgs ...interface{}) bool

NotCalled asserts that the mock function object was not called.

func NotCalledWith

func NotCalledWith(t assert.TestingT, mockFn interface{}, asserter CallInstanceAsserter, msgAndArgs ...interface{}) bool

NotCalledWith asserts that the mock function object was not called with a set of arguments matching the given call instance asserter.

Types

type CallInstanceAsserter

type CallInstanceAsserter interface {
	// Assert determines if the given argument values matches the expected
	// function call.
	Assert(interface{}) bool
}

CallInstanceAsserter determines whether or not a set of argument values from a call of a mock function match the test constraints of a particular function call. See the assertions `CalledWith`, `NotCalledWith`, `CalledOnceWith`, `CalledNWith`, and `CalledAtNWith` for further usage.

func Values

func Values(expectedValues ...interface{}) CallInstanceAsserter

Values returns a new call instance asserter that will match the arguments of each function call positionally with each of the expected values. The assertion behavior in each position can be tuned:

Use the value `mockassert.Skip` to skip validation for values in that parameter position.

Use a function with the type `func(v T) bool` (for any `T`) to override validation for values in that parameter position.

type CallInstanceAsserterFunc

type CallInstanceAsserterFunc func(v interface{}) bool

func (CallInstanceAsserterFunc) Assert

func (f CallInstanceAsserterFunc) Assert(v interface{}) bool

Jump to

Keyboard shortcuts

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