Skip to content

chore(cli): refactor CLI to allow better testing interface + add tests #1693

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alexcastilio
Copy link
Contributor

Description

kubectl-retina CLI does not have e2e tests to validate its behavior. For that, some refactoring is needed.

This PR:

  • refactors CLI code to allow injection of fake kubeclient for testing purposes. This allows the creation of tests that can validate that kubernetes resources are created as expected.
  • Add some tests for capture create and capture delete commands to confirm that main arguments are behaving as expected.

Other tests will be added in the future and this code will be a reference for that.

Related Issue

If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request.

Checklist

  • I have read the contributing documentation.
  • I signed and signed-off the commits (git commit -S -s ...). See this documentation on signing commits.
  • I have correctly attributed the author(s) of the code.
  • I have tested the changes locally.
  • I have followed the project's style guidelines.
  • I have updated the documentation, if necessary.
  • I have added tests, if applicable.

Screenshots (if applicable) or Testing Completed

Please add any relevant screenshots or GIFs to showcase the changes made.

Additional Notes

Add any additional notes or context about the pull request here.


Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

@alexcastilio alexcastilio requested a review from a team as a code owner June 18, 2025 08:48
@alexcastilio alexcastilio force-pushed the alexcastilio/cli-refactor-and-tests branch from 9dcb23e to 320a3b5 Compare June 18, 2025 09:11
kamilprz
kamilprz previously approved these changes Jun 18, 2025
Signed-off-by: Alex Castilio dos Santos <[email protected]>
Signed-off-by: Alex Castilio dos Santos <[email protected]>
Signed-off-by: Alex Castilio dos Santos <[email protected]>
@alexcastilio alexcastilio force-pushed the alexcastilio/cli-refactor-and-tests branch from 320a3b5 to 2d26925 Compare June 27, 2025 08:52
Copy link
Member

@SRodi SRodi left a comment

Choose a reason for hiding this comment

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

Thanks for this @alexcastilio! I approve as I do not see any major issues with this PR, a few generic non-blocking comments:

  • Documentation: Consider updating CLI documentation (help output, README, or developer docs) to reflect the new structure and testing approach.
  • Extending Tests: Future PRs could extend testing to other CLI commands for full coverage.
  • Minor: There are some places where debug output or error messages could be even more descriptive, but overall they are reasonable.

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