mockassert

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 CalledN

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

CalledOnce 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

CalledWith 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`, and `CalledNWith` 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