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

use mockery to generate mocks in data pkg #6244

Conversation

popojk
Copy link
Contributor

@popojk popojk commented Feb 14, 2025

Tracking issue

Related to #149

Why are the changes needed?

FlyteAdmin currently relies on manually crafted mocks, which are cumbersome to maintain and extend for new interfaces. Switching to Mockery v2 generated mocks is a more efficient approach, eliminating repetitive boilerplate code and streamlining the development process.

What changes were proposed in this pull request?

This PR updates the mocks in flyteadmin/pkg/data to use Mockery v2 generated mocks and includes modifications to the related test cases to ensure compatibility.

Check all the applicable boxes

  • All new and existing tests passed.
  • All commits are signed-off.

Summary by Bito

Migration from manual mocks to auto-generated mocks using Mockery v2 in the flyteadmin/pkg/data package. The PR removes old manual mock implementations, adds mockery generation directives, and updates test files to use the new mock interface. This change enhances maintainability and testing consistency by leveraging generated mocks.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 3

@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 14, 2025

Code Review Agent Run #cbfc73

Actionable Suggestions - 5
  • flyteadmin/pkg/async/cloudevent/factory_test.go - 3
    • Mock initialization could be improved · Line 98-98
    • Consider using mock.Mock for testing · Line 98-98
    • Consider using mock.Mock for testing · Line 98-98
  • flyteadmin/pkg/manager/impl/util/data_test.go - 1
  • flyteadmin/pkg/manager/impl/task_execution_manager_test.go - 1
Review Details
  • Files reviewed - 8 · Commit Range: ca101d0..ca101d0
    • flyteadmin/pkg/async/cloudevent/factory_test.go
    • flyteadmin/pkg/data/interfaces/remote.go
    • flyteadmin/pkg/data/mocks/remote.go
    • flyteadmin/pkg/data/mocks/remote_url_interface.go
    • flyteadmin/pkg/manager/impl/execution_manager_test.go
    • flyteadmin/pkg/manager/impl/node_execution_manager_test.go
    • flyteadmin/pkg/manager/impl/task_execution_manager_test.go
    • flyteadmin/pkg/manager/impl/util/data_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 34.88372% with 28 lines in your changes missing coverage. Please review.

Project coverage is 36.87%. Comparing base (b04df59) to head (ca101d0).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
flyteadmin/pkg/data/mocks/remote_url_interface.go 34.88% 27 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #6244       +/-   ##
===========================================
- Coverage   50.51%   36.87%   -13.64%     
===========================================
  Files        1162     1318      +156     
  Lines       91811   134739    +42928     
===========================================
+ Hits        46375    49683     +3308     
- Misses      41340    80728    +39388     
- Partials     4096     4328      +232     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 51.92% <34.88%> (-0.02%) ⬇️
unittests-flytecopilot 30.99% <ø> (?)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.22% <ø> (?)
unittests-flyteplugins 54.03% <ø> (ø)
unittests-flytepropeller 42.78% <ø> (ø)
unittests-flytestdlib 55.35% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@flyte-bot
Copy link
Collaborator

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Testing - Migration to Mockery v2 Generated Mocks

remote.go - Added mockery generation directive for RemoteURLInterface

remote.go - Removed manual mock implementation

remote_url_interface.go - Added auto-generated mock implementation using mockery v2

factory_test.go - Updated mock initialization to use new interface

execution_manager_test.go - Updated mock usage to use mockery expectations

node_execution_manager_test.go - Migrated to new mock implementation

task_execution_manager_test.go - Updated test cases to use mockery mocks

data_test.go - Converted to use new mock implementation

Copy link
Contributor

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

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

Thank you!

@eapolinario eapolinario merged commit 0634811 into flyteorg:master Feb 14, 2025
51 of 53 checks passed
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