Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(tests): use mockery constructors to ensure assertions #2500

Merged
merged 6 commits into from
Sep 2, 2022

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented Apr 28, 2022

Changes

  • Use generated mockery constructors for mockery mocks to ensure assertions are done in the test
  • Fix bugs caused by the now-fixed mock assertions
  • Remove existing .Assert* mocks calls

Tests

All unit tests passing

Issues

Primary Reviewer

@EclesioMeloJunior

@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch 2 times, most recently from c6130b5 to 07a6e7e Compare April 28, 2022 15:26
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch from 07a6e7e to 70fe90b Compare May 4, 2022 14:11
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch from 70fe90b to 636d8ff Compare May 12, 2022 16:25
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch from 636d8ff to c28019c Compare July 4, 2022 22:20
@qdm12 qdm12 changed the title chore(tests): upgrade mockery from v2.10.6 to v2.12.1 chore(tests): use mockery constructors to ensure assertions Jul 7, 2022
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch 10 times, most recently from c3c777e to 410b1dc Compare August 18, 2022 16:00
@qdm12 qdm12 marked this pull request as ready for review August 18, 2022 16:17
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch 2 times, most recently from cc6bc64 to d48da71 Compare August 19, 2022 12:54
lib/babe/babe.go Outdated
Comment on lines 172 to 175
if cfg.BlockImportHandler == nil {
return nil, errNilBlockImportHandler
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note this is removed to allow to have nil block import handler in test code.
Anyway imo this check shouldn't be there, and we should panic if we try to pass a nil handler.

Comment on lines -65 to -76
if cfg == nil {
cfg = &ServiceConfig{
Authority: true,
}
}

cfg.BlockImportHandler = new(mocks.BlockImportHandler)
cfg.BlockImportHandler.(*mocks.BlockImportHandler).
On("HandleBlockProduced",
mock.AnythingOfType("*types.Block"), mock.AnythingOfType("*storage.TrieState")).
Return(nil)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

note this is pushed back up to the caller (tests), since it was differing from one test to the other.

Copy link
Contributor

@jimjbrettj jimjbrettj left a comment

Choose a reason for hiding this comment

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

Looks good. I will probably wait to merge my branch in so that I can use these changes and not have to duplicate (or create more conflicts)

@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch from d48da71 to e4706b2 Compare August 29, 2022 22:13
@qdm12 qdm12 force-pushed the qdm12/mockery-v2.12.1 branch from e4706b2 to 53b057b Compare September 2, 2022 17:21
@qdm12 qdm12 merged commit 78a1dbd into development Sep 2, 2022
@qdm12 qdm12 deleted the qdm12/mockery-v2.12.1 branch September 2, 2022 21:13
qdm12 added a commit that referenced this pull request Sep 6, 2022
- Use generated mockery constructors for mockery mocks to ensure assertions are done in the test
- Fix bugs caused by the now-fixed mock assertions
- Remove existing `.Assert*` mock method calls
- Fix data race in storage observers
@github-actions
Copy link

🎉 This PR is included in version 0.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants