Closed
test: pkg/cmdutil 核心模块覆盖率不达标 (52.0%) #313
aflyingtoAdd on Jun 26Closed at 28 days ago
aflyingto
Aug 9 Comments:
Aug 9 Comments:
langjitianya008
29 days ago Comments:
29 days ago Comments:
验证记录
- 当前版本或分支: origin/main (
64d1027) - 验证时间: 2026-10-09
- 复现命令:
go test -count=1 -coverprofile=cover.out ./pkg/cmdutil/ && go tool cover -func=cover.out - 实际结果: 覆盖率 73.6%(较 issue 创建时 52.0% 已有提升,但仍低于 80% 门槛)。函数级缺口:NewFactory 0%、TestFactory 0%、SetTopicAnnotation 0%、AddFormatFlag 0%、AddTimeFormatFlag 0%、AddTemplateFlag 0%、AddJSONFlag 0%、DefaultToken 0%、AuthenticatedClientFromFactory 0%、FormatAPIID 41.7%、ConfirmTokenDisclosure 61.5%
- 预期结果: 核心模块覆盖率 ≥ 80%(spec/foundations/testing-guide.md)
- 时间线检查: 2026-08-09 triage 复核确认缺口仍存在;当前无关联 PR、无 assignee、无认领评论,不存在重复交付风险
- 结论: 继续修复——补充上述缺口函数单元测试,目标覆盖率 ≥ 80%


langjitianya008
29 days ago Comments:
29 days ago Comments:
开发进度
- 当前状态: in-progress
- 根因: pkg/cmdutil 多个导出函数(factory.go、format.go、output.go、flag_annotations.go、auth.go 部分函数)长期无单元测试,FormatAPIID/ConfirmTokenDisclosure 分支覆盖不全,整体覆盖率 73.6% 低于核心模块 80% 要求
- 主要修改: 新增 factory_test.go、format_test.go、token_confirm_test.go,扩展 errors_test.go、auth_test.go、output_test.go、flag_annotations_test.go
- 影响范围: 仅测试文件,无生产代码改动
- 单元测试: 开发中
- 构建: 待验证
- 实际命令验证: 不适用(纯测试补充,无命令行为变更)
- 安全影响: 无(不涉及凭证、网络调用逻辑变更)
- 文档同步: 无需更新 docs/COMMANDS.md(无命令行为变更)
- 风险或未覆盖项: 低风险,仅新增测试
- 关联 PR: 待提交


29 days ago Associated pull request
28 days ago Close issue
发现来源
Agent 3 - 测试审查 (Critical)
位置
pkg/cmdutil/目录 — factory.go, format.go, output.go, flag_annotations.go 无测试证据
go test -coverprofile=/tmp/cov.out -coverpkg=./pkg/cmdutil/... ./pkg/cmdutil/... go tool cover -func=/tmp/cov.out | grep total # 输出: total: (statements) 52.0%errors_test.go(137行) 测试了 ExitCode() 和 FormatAPIID()。但
factory.go(87行, 核心 Factory 模式),format.go,output.go,flag_annotations.go的测试覆盖不足或缺失。影响评估
Factory 模式是项目中所有命令的依赖注入核心。
NewFactory()和TestFactory()未经测试意味着它们的默认行为(如默认 HTTP 客户端创建、Git 仓库检测)可能在不同环境下产生不同结果。spec/foundations/testing-guide.md要求核心模块覆盖率 ≥ 80%。建议修复方向
factory.go创建factory_test.go,验证 TestFactory() 返回各字段的正确性confirm_test.go是否充分覆盖确认流程format.go和output.go中的格式化函数补充测试🤖 Generated by multi-agent code review workflow