Skip to content

refactor: replace all cmd.SetArgs to testutil.SetArgs in the same module#18899

Closed
levisyin wants to merge 0 commit into
cosmos:mainfrom
levisyin:feat/replace-setargs
Closed

refactor: replace all cmd.SetArgs to testutil.SetArgs in the same module#18899
levisyin wants to merge 0 commit into
cosmos:mainfrom
levisyin:feat/replace-setargs

Conversation

@levisyin
Copy link
Copy Markdown
Contributor

Description

Refer to #18876 .

Replacing all cmd.SetArgs to testutil.SetArgs in module github.com/cosmos/cosmos-sdk.

BTW, as we moved wrapped SetArgs to internal package (See comment), I'm not able to replace cmd.SetArgs to testutil.SetArgs in extracted modules. @julienrbrt Sir, do you have some ideas about how to solve this? Shall we add wrapped SetArgs to all extracted modules?

@levisyin levisyin requested a review from a team December 27, 2023 07:40
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 27, 2023

Walkthrough

The overarching change is a refactoring of test code across several files. The update involves standardizing the way command-line arguments are set in tests by replacing the direct use of cmd.SetArgs with a utility function internaltestutil.SetArgs. This change likely aims to centralize the argument-setting logic, making the tests cleaner and possibly introducing additional behind-the-scenes functionality.

Changes

Files Change Summary
.../add_ledger_test.go, .../add_test.go Replaced cmd.SetArgs with internaltestutil.SetArgs for setting up command arguments in tests.
.../delete_test.go, .../list_test.go, .../migrate_test.go, .../mnemonic_test.go, .../rename_test.go Replaced cmd.SetArgs with internaltestutil.SetArgs for handling command arguments in various key management tests.
server/util_test.go, testutil/cli/cmd.go, version/version_test.go Introduced internaltestutil package and replaced cmd.SetArgs with internaltestutil.SetArgs for command initialization and argument setting.

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 your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your comments unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions Bot added C:CLI C:Keys Keybase, KMS and HSMs labels Dec 27, 2023
Comment thread server/util_test.go Outdated
@julienrbrt
Copy link
Copy Markdown
Contributor

Yes, this is good. We want to avoid to add additional SDK imports.
We could indeed duplicate the package in an internal package of the respective module if needed.
However, I'd check if we rely on the buggy behavior before replacing it. If not I don't think it is worthwhile to replace it everywhere.

@levisyin levisyin marked this pull request as draft December 27, 2023 08:37
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the Stale label Jan 27, 2024
@levisyin levisyin closed this Jan 27, 2024
@levisyin levisyin force-pushed the feat/replace-setargs branch from 5547030 to b947b02 Compare January 27, 2024 12:35
@levisyin
Copy link
Copy Markdown
Contributor Author

Close this and I will reopen a new one these days

@levisyin levisyin deleted the feat/replace-setargs branch January 27, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C:CLI C:Keys Keybase, KMS and HSMs Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants