shad-go/lectures/04-testing/gomock/example_test.go
2020-03-19 16:23:32 +03:00

25 lines
380 B
Go

package example
import (
"testing"
gomock "github.com/golang/mock/gomock"
)
func TestFoo(t *testing.T) {
ctrl := gomock.NewController(t)
// Assert that Bar() is invoked.
defer ctrl.Finish()
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)
}