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.