test(hub-server): 最后两个巨型测试文件按生产域归位——agent_team_test.go 3176行/64Test 与 repository_test.go 2221行/55Test 双双删除,119 Test 逐字搬进 19 个域文件(Test名集合/helper集合/=== RUN 418/PASS 284 四路守恒 diff rc=0,文件级 //nolint:gosec 随之消失且 golangci-lint 两包 0 issues) - #2294
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
DeliciousBuding
enabled auto-merge (squash)
September 3, 2026 14:57
… crud/member/assignment_lifecycle/route_decision/approval/compete/review 7 个域测试文件(13+4+13+9+8+3+1),12 个 Test 并入既有 agent_team_run_test.go、1 个并入 route_helpers_test.go,共享夹具与 mock 类型统一收进 helpers_test.go,原巨型文件删除;Test 名集合 117=117、helper 集合 107=107、=== RUN 180=180、0 SKIP(纯搬家零行为变更) Co-authored-by: Cursor <cursor@vectorcontrol.tech>
…建 db/device/user/session/message/message_reaction/message_attachment/friendship/notification/attachment/session_member/refresh_token 12 个域测试文件(1+5+4+4+10+4+2+7+3+1+4+2),8 个 Test 并入既有 agent_test.go,shared 夹具 setupSQLite/createTestSession/strPtr 收进新 helpers_test.go,原巨型文件删除;SSOT 锚点 repository_test.go→helpers_test.go(夹具 DDL 随迁);Test 名集合 171=171、helper 集合 58=58、=== RUN 238=238、SKIP 2=2(纯搬家零行为变更) Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
force-pushed
the
test/hub-giant-test-split
branch
from
September 3, 2026 14:58
e062b49 to
ad725f3
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
一句话
hub-server 最后两个巨型测试文件按生产域归位:
internal/service/agentteam/agent_team_test.go(3176 行 / 64 Test)与internal/repository/repository_test.go(2221 行 / 55 Test)双双删除,119 个 Test 逐字搬进 19 个域测试文件 + 2 个既有域文件,共享夹具各自收进本包helpers_test.go(27 文件,+5603 / −5398,净 +205 行=拆文件的 package/import/文件头固有成本,非新增断言)。两个包内的生产代码早已按域切分(
agent_team_run.go/agent_team_crud.go/…、device.go/session.go/friendship.go/…),测试侧的这两个 leftovers 是唯一还按"一个文件装整包"的地方。同批已合的 #2288 对edge-server的handlers_test.go(3792→184 行)做了同一件事。拆分结果
agentteam(删 3176 行 / 64 Test)
agent_team_crud_test.goagent_team_member_test.goassignment_lifecycle_test.goroute_decision_test.goagent_team_approval_test.goagent_team_compete_test.goagent_team_review_test.goagent_team_run_test.goroute_helpers_test.gohelpers_test.gorepository(删 2221 行 / 55 Test)
db_test.go1 ·device_test.go5 ·user_test.go4 ·session_test.go4 ·message_test.go10 ·message_reaction_test.go4 ·message_attachment_test.go2 ·friendship_test.go7 ·notification_test.go3 ·attachment_test.go1 ·session_member_test.go4 ·refresh_token_test.go2agent_test.gosetupSQLite/createTestSession/strPtr收进新helpers_test.go守恒证据(主机独立复跑,不是采信 lane 报告)
func Test*名集合(agentteam)func Test*名集合(repository)go test -v的=== RUN排序集合(两包合计,含子测试路径)--- PASS名集合(两包合计)--- SKIPTestMigration0040AuditEventsPostgresUpProtectsTruncate、TestMigration0071PostgresUpCreatesTrgmIndexForMessageSearch(PG-only,master 基线即 SKIP)--- FAIL两包均内存 sqlite + sqlmock,无外部依赖,
-count=1实跑:agentteamok 1.162s、repositoryok 11.125s。//nolint:gosec处置(本批唯一"减少抑制"的点)master 的
agent_team_test.go:1带文件级//nolint:gosec // 测试 fixture:凭据模式字符串…。该文件被删除后没有把这条抑制凭空补到新文件上,而是实测确认它已无必要:golangci-lint run ./internal/service/agentteam/... ./internal/repository/...(本机 v2.12.2,仓库配置run.tests: true)→0 issuesgolangci-lint run --default=none --enable=gosec同两包 →0 issuespython3 scripts/verify/verify-hub-lint-ratchet.py→ rc=0(0 findings, all baseline-registered;hub-lint-baseline.json的 findings 为空 ⇒ 任何新 finding 即红)git grep -hoE "\"[A-Za-z0-9_-]*(secret|token|password|apikey|api_key)[A-Za-z0-9_-]*\""master vs 分支 → agentteam 13=13、repository 7=7,diffrc=0门禁(本机 huawei-dev 实跑)
go build ./...(hub-server)go vet ./...(hub-server)go test ./internal/service/agentteam/... ./internal/repository/... -v -count=1gofmt -l两个包目录python3 scripts/verify/verify-test-sleep-ratchet.pypython3 scripts/verify/verify-hub-lint-ratchet.pybash /tmp/run-validate.sh <worktree>(61 条 CI validate 命令,含 commit-msg / diff --check / check-secrets)PASS=61 FAIL=0 SKIP(merge-ref)=1(主机复跑 1m08s)暗卷(主机独立重跑,证明搬家后测试仍然会红)
isTerminalTeamRunStatus的 terminal 集合从Completed/Failed/Cancelled改成只有Completed→--- FAIL: TestIsTerminalTeamRunStatusIncludesCancelledWithoutCancelAPI,失败定位落在搬家后的新位置route_helpers_test.go:270/272;git checkout --还原后ok 1.162s。WrapNotFound的errors.Is(err, gorm.ErrRecordNotFound)分支从return mappedErr改成return err→--- FAIL: TestWrapNotFound,定位新文件db_test.go:15/16;还原后ok 11.125s。git status --short为空(无残留变异)。顺带必需的一处锚点更新
internal/repository/user_upsert_predicate_test.go的 SSOT 锚点表里{"fixture repository_test.go", "repository_test.go"}→{"fixture helpers_test.go", "helpers_test.go"}(1 行)。该测试本身就是"TokenDance sub predicate 必须在每个夹具 DDL 里出现"的守卫,夹具文件改名后锚点必须随迁,否则守卫会指向不存在的文件。未验证 / 边界(如实)
go test ./...(4C8G,磁盘 96%);只跑两个被改包 + 主机复跑 61 条 validate。stringPtr/strPtr两个同义 helper 在拆前就并存,本批未合并(合并会改夹具签名,属行为无关但另一批的事),仅原样搬进helpers_test.go。关联
round-71 消融/归位批第 3 发。同批:#2288(edge-api
handlers_test.go3792→184)、#2289(docs 死实体)、#2291(projects port 死面 −879 行)、#2292(reference/墓碑机制 −137 行)、#2293(gen/schemas跟踪结论落盘)。