Skip to content

Conversation

@mayuka-c
Copy link
Contributor

This PR refactors the generate.go file to make the getExecutablePath function mockable, enabling better testability for functions that rely on it.

The Executable func was introduced as part of this PR: #5081 which makes the os to use currently running executable which would fail for our UTs as it would try to use testing executable. With this change, it would enable us to mock according to our testing needs.

Here's the UT PR which I'm currently working on where I had made this change and validated: #5074.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 16, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mayuka-c
Once this PR has been reviewed and has the lgtm label, please assign kavinjsir for approval. For more information see the 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

@k8s-ci-robot
Copy link
Contributor

Hi @mayuka-c. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 16, 2025
@mayuka-c mayuka-c changed the title 🌱 Introduce Mockable getExecutablePath for Testing in Generate 🌱 (CLI - Alpha) Introduce Mockable getExecutablePath for Testing in Generate Sep 16, 2025
@camilamacedo86
Copy link
Member

Hi @mayuka-c

Thank you so much for this one 🙏

Just to clarify — we don’t need to reach 100% coverage. I’ll try to describe the issue more clearly to highlight what’s actually missing.
We only need to add unit tests where it’s reasonable; we already have a lot of e2e tests that aren’t counted by Coveralls.

Also, we don’t need to change existing code just to increase coverage.
It would be better to include any additional tests as part of the related PRs, so we don’t add unnecessary requirements or discover later that they weren’t needed.

Based on that, I’ll go ahead and close this one for now.
If you notice that additional tests are required in a future PR, we can revisit it then.

Thanks again for your great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants