Add interface mocks for SDK using mockery #746
Conversation
…ok reader, key reader, document reader, and index reader
📝 WalkthroughWalkthroughAdds mock-generation configuration, a Makefile target, docs, codecov and go.mod updates, and 15+ autogenerated testify/mock files under Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Failure to add the new IP will result in interrupted reviews. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request adds generated interface mocks using mockery to facilitate unit testing for SDK consumers and contributors. The mocks are generated using the testify/mock framework and provide a comprehensive set of test doubles for all public interfaces in the SDK.
Changes:
- Added mockery configuration file (
.mockery.yml) to define mock generation settings - Updated Makefile with a new
mocktarget for regenerating mocks - Added comprehensive documentation in README.md with usage examples
- Updated CONTRIBUTING.md with instructions for generating mocks when modifying interfaces
- Generated 19 mock files covering all major SDK interfaces (ServiceManager, IndexManager, DocumentManager, etc.)
Reviewed changes
Copilot reviewed 19 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.mockery.yml |
Configuration file defining mockery settings for generating mocks from SDK interfaces |
makefile |
Added mock target and mockery installation in requirements |
README.md |
Added "Using Mocks for Testing" section with practical examples and available mocks list |
CONTRIBUTING.md |
Added instructions for regenerating mocks when modifying interfaces |
mocks/*.go |
Generated mock implementations for all SDK interfaces using testify/mock |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@README.md`:
- Around line 308-347: The README code blocks use hard tabs which markdownlint
flags (MD010); replace all hard tab characters with spaces in the fenced Go
examples so indentation is spaces-only—update the CreateMyIndex example and the
unit test example (symbols: CreateMyIndex, TestCreateMyIndex, mockClient,
expectedConfig) to use spaces for indentation and align code blocks consistently
to remove tabs.
- Around line 43-44: The TOC nested list is over-indented; update the
indentation of the nested items so they use 2-space nesting: adjust the lines
for "Using mocks for testing" and its child "Available Mocks" to the correct
2-space indent level (reduce the current extra spaces) so the Markdown TOC
conforms to MD007.
🧹 Nitpick comments (1)
makefile (1)
3-7: Pin the mockery binary used bymake mockto avoid version drift.
mockeryon PATH could be v2 and incompatible with.mockery.ymlv3 options. Consider invoking the pinned version directly (or ensure PATH resolves to v3.6.1).Proposed fix (use pinned version)
mock: `@echo` "Generating mocks..." `@mkdir` -p mocks - `@mockery` + `@go` run github.com/vektra/mockery/[email protected] `@echo` "✓ Mock generation complete"If you keep
go install [email protected], make sure the PATH resolves to that exact binary whenmake mockruns.Also applies to: 15-15
@curquiza @ElyarSadig We are experiencing an issue with meilisearch-go/integration/meilisearch_test.go Lines 2708 to 2770 in 5a9049d |
|
@ja7ad |
I don’t think this issue is caused by the test data, as these tests used to passed without any problems. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #746 +/- ##
=======================================
Coverage 88.53% 88.53%
=======================================
Files 22 22
Lines 3262 3262
=======================================
Hits 2888 2888
Misses 216 216
Partials 158 158 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@ja7ad and @ElyarSadig |
Yw, No fixed issue by PR #750. Thank you @Strift |
|
@ElyarSadig Please review |

Pull Request
Related issue
Fixes #745
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit
Documentation
Chores
Tests