test(client): wrap cmd.SetArgs to fix bugs for cmd.SetArgs#18876
Conversation
WalkthroughThe codebase underwent a refactor where the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
| // SetArgs sets arguments for the command. It is desired to replace the cmd.SetArgs in all test case, as cmd.SetArgs doesn't reset flag value as expected. | ||
| // | ||
| // see https://github.com/spf13/cobra/issues/2079#issuecomment-1867991505 for more detail info | ||
| func SetArgs(cmd *cobra.Command, args []string) { |
There was a problem hiding this comment.
We should be mindful of new public api we add. Can we maybe have this in an internal package?
Concerning using it everywhere in the sdk, we should really really watch out that we don't increase the reliance on the sdk for already extracted modules.
There was a problem hiding this comment.
@julienrbrt Hi sir, I have moved it to internal/testutil
…osmos#18876)" This reverts commit ae19acc.
Description
This pr is aim to provide a simple way
testutil.SetArgsto replacecmd.SetArgsin test as there is bug forcmd.SetArgs, see spf13/cobra/issues/2079 for more detail info about the bug.Reason
Refer to pr #18557 added test, it's fussy to explicitly set all args that has changed before in writing unit test. We should concentrate on the new test case, no need to care about what this case's args will take effects to other test cases.
Test
I have replaced
cmd.SetArgstotestutil.SetArgsin keys show test, it works well. If this pr LGTY, I will draft a new pr to check if there are test cases that depend on the bug behavior of SetArgs, and replacecmd.SetArgstotestutil.SetArgsfor all test file.