From f8454d310bf6d68d8b6ffde662e4f075bb2ce284 Mon Sep 17 00:00:00 2001 From: wangdefa <1+wangdefa@noreply.gitea.bcde.io> Date: Tue, 20 Oct 2026 22:32:42 -0700 Subject: [PATCH] =?UTF-8?q?test:=20=E5=85=AC=E5=8F=B8=E5=BD=92=E5=B1=9E?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9D=9F=E5=88=A0=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=20CI=20=E9=87=8D=E8=AF=95=E8=B7=A8?= =?UTF-8?q?=E8=BD=AE=E6=B1=A1=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/company_scope_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/company_scope_test.go b/db/company_scope_test.go index 31fcbc3..e9a7f8c 100644 --- a/db/company_scope_test.go +++ b/db/company_scope_test.go @@ -342,6 +342,11 @@ func TestCompanyScopeAttribution(t *testing.T) { if err != nil { t.Fatalf("UpsertCompany: %v", err) } + // 公司名每轮唯一,但 CIDR(198.51.100.0/24)是硬编码的。CI 重试会复用同一个库, + // 若不删公司,上一轮留下的 scope 行会和本轮争夺同一网段——IP 归属按 company_id 升序 + // 取第一个,于是落到上一轮那个更小的 id 上(曾现 company_id=26, want 64)。删公司会 + // 级联清掉 company_scope,让重试从干净状态开始。LIFO:本清理先于上面的删资产+关库跑。 + t.Cleanup(func() { _ = cs.DeleteCompany(cid) }) // a pre-existing asset (inserted BEFORE any scope) — must be back-filled. preID, err := as.UpsertSubdomain(UpsertSubdomainReq{Domain: sub})