You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @fly333sky , thanks for your contribution to the community.
Bot Usage Manual
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.
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
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.
背景
[任务] app-cla-server 接入 obs-sdk:结构化日志 + 指标并暴露 /metrics(#1938 / #2061)(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)
改动内容
fix(app-cla-server): 修复 corp_pdf_email.go 测试未走 do() 真实路径导致覆盖率不达标
问题
上一轮预览失败:
TestCorpPDFEmailPathRecordsEmailMetric直接调用recordEmailSent()而非通过corp_pdf_email.do()真实代码路径,导致do()和genFile()覆盖率 0%,增量覆盖率 10.8% < 80%。改动
仅修改
worker/metrics_test.go(测试文件),无业务源码改动:TestCorpPDFEmailPathRecordsEmailMetric(仅调 helper 未走 do())fakePDFGenerator(实现pdf.IPDFGenerator)+setPDFGenerator注入/还原 helperTestCorpPDFEmailDoRecordsMetrics— do() 成功路径:验证email_sent_total{outcome="sent"}+pdf_generated_total{outcome="success"}在真实 /metrics 文本中断言TestCorpPDFEmailDoEmailFailureRecordsFailedMetric— 邮件发送失败:验证email_sent_total{outcome="failed"}记录TestCorpPDFEmailDoPDFFailureRecordsFailedMetric— PDF 生成失败:验证pdf_generated_total{outcome="failed"}记录,do() 提前返回TestCorpPDFEmailDoGenMsgFailure— genMsg() 失败路径:验证 do() 中 genFile 成功后 genMsg 失败的 return err 分支TestCorpPDFEmailGenFileSkipsWhenFileExists— genFile() fileExist 早返回路径TestCorpPDFEmailCleanRemovesFile— clean() 文件存在时删除TestCorpPDFEmailCleanNoFile— clean() 文件不存在时不 panic覆盖率
do(): 0% → 100%genFile(): 0% → 100%clean(): 0% → 75%fileExist(): 100%buildCorpSigningInfo(): 83.3%genEmailTmpl(): 83.3%UT 文件
worker/metrics_test.go:新增 fakePDFGenerator、setPDFGenerator、createTempPDFFile、newTestCorpPDFEmail、gatherMetricsText 辅助 + 7 个测试用例,覆盖 do() 全部分支(成功/邮件失败/PDF失败/genMsg失败)+ genFile() 全部分支(成功/失败/fileExist早返回)+ clean() 双路径相关 Issue
resolve https://github.com/opensourceways/backlog/issues/2552
AI 使用声明
当前 PR 是否有 AI 参与:
/ai-develop-preview