Skip to content

test(group-context): 按阈值自动淘汰用例改为真正覆盖 maxRows 条数淘汰 - #2849

Merged
deepcoldy merged 1 commit into
deepcoldy:masterfrom
MoonBall:fix/group-context-maxrows-test
Nov 5, 2026
Merged

deepcoldy merged 1 commit into
deepcoldy:masterfrom
MoonBall:fix/group-context-maxrows-test

Conversation

@MoonBall

@MoonBall MoonBall commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

改了什么

test/group-context-store.test.ts 中「upsert 会按阈值自动触发淘汰」用例:

  • 夹具时间从 1970 年的 1000 + i 改为保留窗口内的 now - i * 1000,并显式注入 now,按年龄淘汰分支不再参与;
  • 断言从 count <= 20 / prunedCount > 0 收紧为 count === 20、prunedCount === 10,并校验留下的正好是最新的 20 条(om_1..om_20);
  • 保留 retentionGap 断言。

为什么

原用例的行龄远超默认 30 天窗口,每次写入都被按年龄分支整批删光(count=0),count <= 20 恒成立,实际没覆盖 maxRows 条数淘汰。详见 #2818。

影响面

仅测试文件,不涉及生产代码。

测试验证

  • npx vitest run test/group-context-store.test.ts:65 passed
  • bun test test/group-context-store.test.ts(bun 1.4.3):65 pass / 0 fail
  • tsc --noEmit:通过
  • 变异复验:
    • 禁用 pruneGroupContext 的按条数分支 → 本用例变红(同时还有另外 3 个 maxRows 用例变红)
    • 禁用按年龄分支 → 本用例仍绿,证明它不再依赖年龄淘汰

Closes #2818

夹具改用保留窗口内的时间并注入受控 now,避免按年龄分支先把行删光;
断言收紧为 count=20、prunedCount=10,并校验留下的是最新 20 条。

Closes deepcoldy#2818
@deepcoldy

Copy link
Copy Markdown
Owner

你好,这个 PR 的自动评审群已建,麻烦点击链接加入群聊、查看评审意见并跟进后续修改:
https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=466r45ff-cef3-43ad-b8b4-0b33d42257af

另外你暂时不在自动拉群名单里,也可以把 GitHub 账号和飞书信息补进名单文档,补好后后续评审会自动拉你进群:https://bytedance.larkoffice.com/wiki/WJ1nwWbtxi89erkNGNbcgkt9nUe

(本条为自动流程发出的提示消息)

@deepcoldy
deepcoldy merged commit 5d3ed17 into deepcoldy:master Nov 5, 2026
11 checks passed
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

🚀 Released in v3.57.2

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.

test(group-context): store「按阈值自动触发淘汰」用例被按年龄分支提前满足,未覆盖 maxRows 条数淘汰

2 participants