Last active
February 15, 2016 19:58
-
-
Save vladlosev/fad989f51776c2061d72 to your computer and use it in GitHub Desktop.
Test for .Times(0) functionality in github.com/stretchr/mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mock | |
import ( | |
"errors" | |
"testing" | |
) | |
type TestInterface interface { | |
TestMethod(a, b, c int) (int, error) | |
} | |
type TestImplementation struct { | |
Mock | |
} | |
func (i *TestImplementation) TestMethod(a, b, c int) (int, error) { | |
args := i.Called(a, b, c) | |
return args.Int(0), errors.New("Whoops") | |
} | |
func TestTimesZeroNoCalls(t *testing.T) { | |
var mockedService = new(TestImplementation) | |
mockedService.On("TestMethod").Return(5, 6, 7).Times(0) | |
mockedService.AssertExpectations(t) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment