assertions

package
v0.0.0-...-f0583b4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: MIT Imports: 6 Imported by: 0 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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldHaveExpectationsMet

func ShouldHaveExpectationsMet(iFace interface{}, args ...interface{}) string

ShouldHaveExpectationsMet is a goconvey style assertion. It is similar to https://godoc.org/github.com/stretchr/testify/mock#Mock.AssertExpectations, and asserts that everything specified with On and Return was in fact called as expected.

See Also

https://github.com/smartystreets/goconvey/wiki/Custom-Assertions

func ShouldHaveReceived

func ShouldHaveReceived(iFace interface{}, args ...interface{}) string

ShouldHaveReceived is a goconvey style assertion. It is similar to https://godoc.org/github.com/stretchr/testify/mock#Mock.AssertCalled , and it asserts that the specified method was called.

See Also

https://github.com/smartystreets/goconvey/wiki/Custom-Assertions

Example
Convey("Given A mock", t, func() {
	mock := new(mocks.Foo)
	Convey("That is expecting Bar to be called", func() {
		mock.On("Bar").Return("Hello World")
		Convey("After we call it", func() {
			mock.Bar()
			Convey("It should have received the call", func() {
				So(mock, ShouldHaveReceived, "Bar")
			})
		})
	})
})

func ShouldHaveReceivedN

func ShouldHaveReceivedN(iFace interface{}, args ...interface{}) string

ShouldHaveReceivedN is a goconvey style assertion. It is similar to https://godoc.org/github.com/stretchr/testify/mock#Mock.AssertNumberOfCalls , and it asserts that the specified method was called N times.

See Also

https://github.com/smartystreets/goconvey/wiki/Custom-Assertions

Example
Convey("Given A mock", t, func() {
	mock := new(mocks.Foo)
	Convey("That is expecting Bar to be called", func() {
		mock.On("Bar").Return("Hello World")
		Convey("After we call it twice", func() {
			mock.Bar()
			mock.Bar()
			Convey("We can assert that it was called twice", func() {
				So(mock, ShouldHaveReceivedN, "Bar", 2)
			})
		})
	})
})

func ShouldNotHaveReceived

func ShouldNotHaveReceived(iFace interface{}, args ...interface{}) string

ShouldNotHaveReceived is a goconvey style assertion. It is similar to https://godoc.org/github.com/stretchr/testify/mock#Mock.AssertNotCalled , and it asserts that the specified method was not called.

See Also

https://github.com/smartystreets/goconvey/wiki/Custom-Assertions

Example
Convey("Given A mock", t, func() {
	mock := new(mocks.Foo)
	Convey("That is expecting Bar to be called", func() {
		mock.On("Bar").Return("Hello World")
		Convey("Can assert that bar hasn't been called", func() {
			So(mock, ShouldNotHaveReceived, "Bar")
		})

	})
})

Types

This section is empty.

Jump to

Keyboard shortcuts

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