Skip to content

refactor(test): unify config compat helpers to use cobra subcommand tree - #656

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
DoTuanAnh2k1:refactor/config-compat-cobra
Aug 1, 2026
Merged

refactor(test): unify config compat helpers to use cobra subcommand tree#656
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
DoTuanAnh2k1:refactor/config-compat-cobra

Conversation

@DoTuanAnh2k1

Copy link
Copy Markdown
Contributor

runConfig and parseConfigArgs in compat_test.go still did manual arg slicing and hand-written subcommand dispatch, while the other compat helpers (runSession, parseReviewFlags, parseScanFlags) were already migrated to cobra in #625. That duplicated the routing the production config command defines with cobra, so the two could drift.

This rebuilds runConfig as a fresh cobra tree that mirrors the production command (set = ExactArgs(2), unset = ExactArgs(1), provider/model = NoArgs), matching the runSession pattern, and drops parseConfigArgs, configAction, and configParseError, which are then unused.

The parseConfigArgs unit tests are removed along with the helper; the same dispatch behavior (unknown subcommand, missing args, provider/model with args, empty args) is already covered by the runConfig tests in config_dispatch_test.go and config_cmd_test.go. Behavior is unchanged and the full suite passes. go test ./... and make check pass.

Closes #638


Disclosure: prepared with AI assistance.

runConfig manually dispatched config subcommands and parseConfigArgs did manual arg slicing, duplicating the routing the production config command already defines with cobra. Rebuild runConfig as a fresh cobra tree mirroring production (matching the runSession pattern), and drop parseConfigArgs, configAction, and configParseError, which are no longer used. Dispatch behavior is unchanged and stays covered by the existing runConfig/config_dispatch tests.

Closes alibaba#638
@CLAassistant

CLAassistant commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: No supported files changed.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 575dfee into alibaba:main Aug 1, 2026
8 checks passed
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.

refactor(test): unify config compat helpers to use cobra subcommand tree

3 participants