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

remove mockResourceDetector #6106

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Conversation

zach593
Copy link
Contributor

@zach593 zach593 commented Feb 10, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

mockResourceDetector isn't working and we don't need it to complete the tests.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Signed-off-by: zach593 <zach_li@outlook.com>
@karmada-bot karmada-bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Feb 10, 2025
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 10, 2025
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.11%. Comparing base (2be7042) to head (33a9490).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6106   +/-   ##
=======================================
  Coverage   48.11%   48.11%           
=======================================
  Files         668      668           
  Lines       55238    55238           
=======================================
  Hits        26579    26579           
  Misses      26928    26928           
  Partials     1731     1731           
Flag Coverage Δ
unittests 48.11% <ø> (ø)

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.

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

The mockResourceDetector is invalid due to the change of the detector BuildResourceBinding and BuildClusterResourceBinding methods. In addition, the test content shows that the mockResourceDetector is normal if the detector is not mocked.

Thanks~
/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 11, 2025
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: XiShanYongYe-Chang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 11, 2025
@karmada-bot karmada-bot merged commit 7cea9dd into karmada-io:master Feb 11, 2025
21 checks passed
@zach593
Copy link
Contributor Author

zach593 commented Feb 11, 2025

I'm not sure if we are talking about the same thing. After testing, these mock methods are not called at all, which is why it still could compile when the function signature is changed.

As for why the mock does not take effect, it is because in the tests, (d *ResourceDetector) ApplyPolicy() and (d *ResourceDetector) ApplyClusterPolicy() are called.
Therefore, when they're calling the methods that "we think are mocked" like d.ClaimClusterPolicyForObject() in these two functions, the receivers d are also *ResourceDetector, so the mock functions have no chance to be called at all.

@XiShanYongYe-Chang

@XiShanYongYe-Chang
Copy link
Member

Thanks @zach593
The mockResourceDetector has not taken effect since it was added, do you mean that?

@zach593
Copy link
Contributor Author

zach593 commented Feb 11, 2025

The mockResourceDetector has not taken effect since it was added, do you mean that?

Yes, it is. 😄

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants