From 4c1821363cc9268cd36a8ec045d5d93e55a57fbb Mon Sep 17 00:00:00 2001 From: guke Date: Fri, 7 Aug 2026 16:10:02 +0800 Subject: [PATCH] =?UTF-8?q?test(wallet):=20=E9=98=B2=E6=AE=8B=E7=BB=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=A1=A5=E8=B7=A8=E6=B8=B8=E6=A0=87=E5=89=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=AD=E8=A8=80(=E6=B8=B8=E6=A0=87=E9=A1=BB?= =?UTF-8?q?=E8=90=BD=E5=9C=A8=E4=BC=9A=E8=AF=9D=E4=B8=A4=E6=88=90=E5=91=98?= =?UTF-8?q?=20id=20=E9=97=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 否则 seeding 顺序若变,用例会退化成非跨游标却仍通过、失守护意义。 (code-review Task 5 的建议) Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_welfare.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_welfare.py b/tests/test_welfare.py index ca4da43..d91d5e5 100644 --- a/tests/test_welfare.py +++ b/tests/test_welfare.py @@ -570,6 +570,11 @@ def test_coin_transactions_pagination_no_phantom_regroup(client) -> None: _seed_coin(db, user.id, 40, "signin", remark="每日签到奖励") # id=n+3 _seed_coin(db, user.id, 4, "feed_ad_reward_comparison", trace_id="t1", ref_id="e2", remark="比价奖励") # id=n+4 = t1 的 rep db.commit() + t1_ids = db.execute( + select(CoinTransaction.id) + .where(CoinTransaction.user_id == user.id, CoinTransaction.trace_id == "t1") + .order_by(CoinTransaction.id) + ).scalars().all() # 第 1 页(limit=2):按 rep 降序 = [t1(rep=n+4, 合计 9), signin(n+3, 40)] p1 = client.get("/api/v1/wallet/coin-transactions?limit=2", headers=_auth(token)).json() assert len(p1["items"]) == 2 @@ -577,6 +582,9 @@ def test_coin_transactions_pagination_no_phantom_regroup(client) -> None: assert p1["items"][0]["amount"] == 9 and p1["items"][0]["merged_count"] == 2 assert p1["items"][1]["biz_type"] == "signin" and p1["items"][1]["amount"] == 40 assert p1["next_cursor"] is not None + # 前置条件:游标(第1页末条 rep)必须严格落在 t1 两成员 id 之间,才是真正的「跨游标」场景; + # 否则用例会退化成非跨游标、悄悄测错形状仍通过,失去回归守护意义。 + assert t1_ids[0] < p1["next_cursor"] < t1_ids[-1] # 第 2 页:只剩另一条 signin(30);t1 的 rep 在游标上,成员虽在游标下也不得成残组重复 p2 = client.get( f"/api/v1/wallet/coin-transactions?limit=2&cursor={p1['next_cursor']}",