Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Replace mockery with mockgen for mock generation #333

Merged
merged 6 commits into from
Feb 22, 2018
Merged

Conversation

ChuntaoLu
Copy link
Contributor

@ChuntaoLu ChuntaoLu commented Feb 17, 2018

This PR switches the mock generation lib from mockery to mockgen, because

  • mockery does not support indirect interface types, such as type alias and type redeclaration
  • mockgen is officially supported by golang

Unfortunately, mockgen currently does not support anonymous struct types (golang/mock#153), so I have to temporarily unexpose client methods that consume/return anonymous struct types.

@coveralls
Copy link

coveralls commented Feb 17, 2018

Coverage Status

Coverage increased (+3.2%) to 71.054% when pulling 939bc7f on lu.mockgen into 0ce0f16 on master.


if ! [ -x "$(command -v mockgen)" ]; then
go get -u github.com/golang/mock/gomock
go get -u github.com/golang/mock/mockgen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooling should be pinned in glide.yaml so we have reproducible results.

@@ -27,7 +27,7 @@ func TestSaveContactsCall(t *testing.T) {
}
clientResponse := &clientContacts.SaveContactsResponse{}

ms.MockClientNodes().Contacts.On("SaveContacts", mock.Anything, mock.Anything, clientRequest).
ms.MockClientNodes().Contacts.EXPECT().SaveContacts(gomock.Any(), gomock.Any(), clientRequest).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like how the mocks are statically typed.

@ChuntaoLu ChuntaoLu merged commit 0057a2e into master Feb 22, 2018
@ChuntaoLu ChuntaoLu deleted the lu.mockgen branch February 22, 2018 01:37
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants