From b222794f02594d5d21ab91c3e8c3b86f85ffb24b Mon Sep 17 00:00:00 2001 From: Rafael Garcia Date: Wed, 5 Feb 2014 15:31:42 -0800 Subject: [PATCH] failing test for #31 --- mock/mock_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mock/mock_test.go b/mock/mock_test.go index 61f9afc..cd06451 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -29,6 +29,13 @@ func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) { i.Mock.Called(yesorno) } +type ExampleType struct{} + +func (i *TestExampleImplementation) TheExampleMethod3(et *ExampleType) error { + args := i.Mock.Called(et) + return args.Error(0) +} + /* Mock */ @@ -383,6 +390,23 @@ func Test_Mock_AssertExpectations(t *testing.T) { } +func Test_Mock_AssertExpectationsCustomType(t *testing.T) { + + var mockedService *TestExampleImplementation = new(TestExampleImplementation) + + mockedService.Mock.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Once() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.TheExampleMethod3(&ExampleType{}) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) { var mockedService *TestExampleImplementation = new(TestExampleImplementation)