2020-03-19 13:23:32 +00:00
|
|
|
package example
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-03-11 14:35:16 +00:00
|
|
|
"github.com/golang/mock/gomock"
|
2020-03-19 13:23:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestFoo(t *testing.T) {
|
|
|
|
ctrl := gomock.NewController(t)
|
|
|
|
|
|
|
|
m := NewMockFoo(ctrl)
|
|
|
|
|
|
|
|
// Asserts that the first and only call to Bar() is passed 99.
|
|
|
|
// Anything else will fail.
|
|
|
|
m.
|
|
|
|
EXPECT().
|
|
|
|
Bar(gomock.Eq(99)).
|
|
|
|
Return(101)
|
|
|
|
|
|
|
|
SUT(m)
|
|
|
|
}
|