Skip to content

[fix][prompt] fix ut map -> list problem#363

Merged
caijialin0626 merged 1 commit intomainfrom
fix/prompt_manage_ut
Dec 24, 2025
Merged

[fix][prompt] fix ut map -> list problem#363
caijialin0626 merged 1 commit intomainfrom
fix/prompt_manage_ut

Conversation

@caijialin0626
Copy link
Copy Markdown
Collaborator

What type of PR is this?
fix

Check the PR title
• [x] This PR title match the format: [][] . For example: [fix][backend] flaky fix
• [x] The description of this PR title is user-oriented and clear enough for others to understand.
• [x] Add documentation if the current PR requires user awareness at the usage level.
• [x] This PR is written in English. PRs not in English will not be reviewed.

PR Title: [fix][prompt] fix unit test flakiness in SaveDraft with snippets

(Optional) Translate the PR title into Chinese
修复 SaveDraft 中 snippets 相关单元测试的不稳定问题

(Optional) More detailed description for this PR
en:
Fixed flaky unit test in TestManageRepoImpl_SaveDraft/create_draft_with_snippets that was failing intermittently due to order dependency when converting map to slice. The test was asserting specific array indices for relations, but Go map iteration order is undefined, causing non-deterministic test results.

Solution:
• Replaced index-based assertions with content-based verification using a map lookup
• Maintained all existing validation logic while eliminating order dependency
• Added descriptive error messages for better debugging

zh:
修复了 TestManageRepoImpl_SaveDraft/create_draft_with_snippets 中的不稳定测试问题,该测试因为 map 转 slice 时的顺序依赖而间歇性失败。测试代码断言特定的数组索引对应关系,但 Go 的 map 迭代顺序是未定义的,导致测试结果不确定。

解决方案:
• 将基于索引的断言替换为基于内容的验证,使用 map 查找
• 保持所有现有验证逻辑的同时消除了顺序依赖
• 添加了描述性错误信息以便更好地调试

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #363   +/-   ##
=======================================
  Coverage   69.41%   69.41%           
=======================================
  Files         616      616           
  Lines       57881    57881           
=======================================
  Hits        40179    40179           
  Misses      14765    14765           
  Partials     2937     2937           
Flag Coverage Δ
unittests 69.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d94ebe...6e7dfcb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@caijialin0626 caijialin0626 merged commit fa7260f into main Dec 24, 2025
17 of 18 checks passed
@caijialin0626 caijialin0626 deleted the fix/prompt_manage_ut branch December 24, 2025 07:41
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.

3 participants