Skip to content

🌱 (cli; alpha commands): Add unit tests for alpha commands [WiP] #4931

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: master
Choose a base branch
from

Conversation

cmallikarjunah
Copy link

Issue: 4925

Adding unit tests

Copy link

linux-foundation-easycla bot commented Jul 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cmallikarjunah
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

Welcome @cmallikarjunah!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @cmallikarjunah. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 16, 2025
@cmallikarjunah cmallikarjunah changed the title 🌱(cli; alpha commands): Add unit tests for alpha commands 🌱WiP (cli; alpha commands): Add unit tests for alpha commands Jul 16, 2025
@cmallikarjunah cmallikarjunah changed the title 🌱WiP (cli; alpha commands): Add unit tests for alpha commands [WiP] 🌱 (cli; alpha commands): Add unit tests for alpha commands Jul 16, 2025
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 16, 2025

When("NewScaffoldCommand", func() {
It("Testing the NewScaffoldCommand", func() {
cmd := NewScaffoldCommand()
Copy link
Member

Choose a reason for hiding this comment

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

The alpha update command internal code it might be nice if we could cover something
However, if you find it too complicated, I suggest skipping pkg/cli/alpha and proceeding to the following directory. ;-)
We have a lot inside that we can add more to, and it is not alpha/experimental staff.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I am working on the update internal code.

Copy link
Member

Choose a reason for hiding this comment

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

Just a tip:

You can validate the code locally with:

  • make lint -> for linter check
  • you can run make lint-fix : to fix automaticly issues ( not all is fixed but is very helpful )

Copy link
Member

Choose a reason for hiding this comment

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

When you finish this one please remove WIP from the title so that we are aware of and we can review/get merged get done ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @cmallikarjunah, I'm currently working on alpha internal update package, are you working on the same or is it different?. I wanted to clarify so that we dont duplicate the work :-)

https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/cli/alpha/internal/update

Copy link
Author

@cmallikarjunah cmallikarjunah Jul 18, 2025

Choose a reason for hiding this comment

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

Ya it's the same @mayuka-c.
Was working on functions of prepare.go yesterday. Planning to continue.
There was no WiP or status for it so I picked it upon Camila's suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, no worries, you can continue

@cmallikarjunah cmallikarjunah changed the title [WiP] 🌱 (cli; alpha commands): Add unit tests for alpha commands 🌱 (cli; alpha commands): Add unit tests for alpha commands Jul 18, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 18, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 20, 2025
@cmallikarjunah cmallikarjunah changed the title 🌱 (cli; alpha commands): Add unit tests for alpha commands 🌱 (cli; alpha commands): Add unit tests for alpha commands [WiP] Jul 20, 2025
@@ -75,7 +75,7 @@ func (opts *Update) defineFromVersion(config store.Store) (string, error) {

func (opts *Update) defineToVersion() string {
if len(opts.ToVersion) != 0 {
if !strings.HasPrefix(opts.FromVersion, "v") {
if !strings.HasPrefix(opts.ToVersion, "v") {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please rebase with master?
So that we have no this change it is fixed and merged now 👍

Entry("options", &Update{ToVersion: "v1.1.0"}),
Entry("options", &Update{FromVersion: "1.0.0"}),
Entry("options", &Update{ToVersion: "1.1.0"}),
Entry("options", &Update{}),
Copy link
Member

@camilamacedo86 camilamacedo86 Jul 20, 2025

Choose a reason for hiding this comment

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

Can we reduce the number of test cases here?

Do we really need all of them to cover the intended scenarios?
It seems like we’re primarily validating support for:

  • FromVersion and ToVersion with and without the v prefix
  • Presence or absence of FromBranch

We’re not actually validating SemVer parsing here, so duplicating every combination may be unnecessary.
Maybe we could simplify this to focus on meaningful permutations only?

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/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.

4 participants