test: 补齐所有命令的标志注册测试,堵住系统性漏洞#39
Merged
Merged
Conversation
added 3 commits
July 17, 2026 02:49
审计发现 9 个标志(start/provider/key/config)没有注册测试。 CLAUDE.md 测试规则第 4 条强化为: "每个 init() 中注册的标志必须在对应 *_cmd_test.go 中有 Lookup 测试, 与标志代码在同一个 PR 中加入" 新增测试文件: - start_cmd_test.go: --provider, --all, --log-format - config_cmd_test.go: --path - provider_cmd_test.go: --target, --port, --genai, --cooldown-sec, --max-retries, --default 现在所有 12 个 CLI 标志各有对应的注册测试。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动
为所有通过
init()注册的 CLI 命令标志添加Lookup测试,确保每个 flag 都能被正确注册和发现。测试文件
start_cmd_test.goTestStartCmd_HasLogFormatFlag,TestStartCmd_HasProviderFlag,TestStartCmd_HasAllFlag--log-format,--provider,--allconfig_cmd_test.go(新增)TestConfigInitCmd_HasPathFlag--pathprovider_cmd_test.go(新增)TestKeyAddCmd_HasNameFlag,TestProviderAddCmd_HasTargetFlag,TestProviderAddCmd_HasPortFlag,TestProviderAddCmd_HasGenaiFlag,TestProviderAddCmd_HasCooldownSecFlag,TestProviderAddCmd_HasMaxRetriesFlag,TestProviderAddCmd_HasDefaultFlag--name,--target,--port,--genai,--cooldown-sec,--max-retries,--default其他
CLAUDE.md: 新增规则 消除 Config 双重表示(Config/TomlProviderConfig 合并) #4 — 每个init()中注册的标志必须在对应*_cmd_test.go中有Lookup测试fix/flag-registration-tests分支(有冲突的 merge 历史)