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

Added UTs for resourceregistry in pkg/generated #5417

Conversation

yashpandey06
Copy link
Contributor

@yashpandey06 yashpandey06 commented Aug 23, 2024

/kind feature

Fixes part of #5236

Description

This PR introduces comprehensive unit tests for the ResourceRegistryLister implementation in the v1alpha1 package. The tests cover the following scenarios:

  • List Method:

    • Verifies behavior with an empty indexer.
    • Confirms correct listing of ResourceRegistry objects when the indexer is populated.
  • Get Method:

    • Tests retrieval of non-existent entries, ensuring a NotFound error is returned.
    • Validates successful retrieval of existing ResourceRegistry objects.
    • Simulates and tests error handling by using a mock indexer that returns an error.

These tests aim to ensure robustness and reliability of the ResourceRegistryLister functionality by covering both typical and edge cases.

Changes

  • Added TestResourceRegistryLister_List to test the List method.
  • Added TestResourceRegistryLister_Get to test the Get method, including error handling.
  • Implemented a mockIndexer to simulate error scenarios.

Does this PR introduce a user-facing change?:
NONE

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 23, 2024
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2024

⚠️ 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 30.60%. Comparing base (bcf68fa) to head (d9ffb9a).
Report is 2 commits behind head on master.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5417      +/-   ##
==========================================
+ Coverage   30.12%   30.60%   +0.48%     
==========================================
  Files         632      632              
  Lines       43936    43936              
==========================================
+ Hits        13236    13448     +212     
+ Misses      29742    29510     -232     
- Partials      958      978      +20     
Flag Coverage Δ
unittests 30.60% <ø> (+0.48%) ⬆️

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.

@yashpandey06
Copy link
Contributor Author

@XiShanYongYe-Chang Please help review this MR too .
Thanks !

@anujagrawal699
Copy link
Contributor

Hey @yashpandey06 can you please update the file name from resourceregistry.go_test.go to resourceregistry_test.go.

@yashpandey06
Copy link
Contributor Author

Hey @yashpandey06 can you please update the file name from resourceregistry.go_test.go to resourceregistry_test.go.

Apologies for that , fixed it

@yashpandey06
Copy link
Contributor Author

Hey @yashpandey06 can you please update the file name from resourceregistry.go_test.go to resourceregistry_test.go.

Apologies for that , it has been fixed , we can move ahead with the review

@yashpandey06
Copy link
Contributor Author

@XiShanYongYe-Chang Please help review this MR too . Thanks !

we can move ahead with the review part

@XiShanYongYe-Chang
Copy link
Member

XiShanYongYe-Chang commented Aug 24, 2024

Hi @yashpandey06 Can you help complete the title, and help squash the commits into one?

@XiShanYongYe-Chang
Copy link
Member

/assign

@yashpandey06
Copy link
Contributor Author

@XiShanYongYe-Chang sure doing it

@yashpandey06 yashpandey06 changed the title Added UTs for resourceregistry for better coverage of critical condit… Added UTs for resourceregistry in pkg/generated/listers/search/v1alpha1/resourceregistry.go Aug 24, 2024
@yashpandey06 yashpandey06 changed the title Added UTs for resourceregistry in pkg/generated/listers/search/v1alpha1/resourceregistry.go Added UTs for resourceregistry in pkg/generated/listers/search Aug 24, 2024
@yashpandey06 yashpandey06 changed the title Added UTs for resourceregistry in pkg/generated/listers/search Added UTs for resourceregistry in pkg/generated Aug 24, 2024
@karmada-bot karmada-bot added the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Aug 24, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from xishanyongye-chang. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

…ions

Signed-off-by: Yash Pandey <[email protected]>

Added UTs for resourceregistry for better coverage of critical conditions

Signed-off-by: Yash Pandey <[email protected]>
@yashpandey06 yashpandey06 force-pushed the test/generated/listers/search/v1alpha1/resourceregistry branch from 3cb6b41 to d9ffb9a Compare August 24, 2024 12:03
@karmada-bot karmada-bot removed the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Aug 24, 2024
@yashpandey06
Copy link
Contributor Author

@XiShanYongYe-Chang Apologies , would be squashing the commits into one in future.
Thanks !

@yashpandey06
Copy link
Contributor Author

@XiShanYongYe-Chang , commits have been squashed , i think we can proceed 🙂

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.

Hi @yashpandey06 the pkg/generated is automatically generated by the code generation tool, so I'm not sure that adding tests for them is necessary. I looked at the kubernetes repository and they don't have test files either.

@yashpandey06
Copy link
Contributor Author

Hi @yashpandey06 the pkg/generated is automatically generated by the code generation tool, so I'm not sure that adding tests for them is necessary. I looked at the kubernetes repository and they don't have test files either.

@XiShanYongYe-Chang so should i close this pr instead ?

@XiShanYongYe-Chang
Copy link
Member

@XiShanYongYe-Chang so should i close this pr instead ?

Let's close it first.

@yashpandey06
Copy link
Contributor Author

yashpandey06 commented Aug 26, 2024

@XiShanYongYe-Chang so should i close this pr instead ?

Let's close it first.

Thanks for your feedback, closing it now .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. 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