refactor(testkit): 消融两层纯转发 shim——删掉 edge/hub internal/testkit 里只把 WaitFor/Eventually 原样转给 pkg/testkit 的 2×25 行复制层,11 个测试文件 import 直指 pkg/testkit(净 −44 行、−1 包) - #2283
Merged
Conversation
…tFor/Eventually 原样转给 pkg/testkit(2×25 行 0 自有行为 0 测试),删掉后 11 个测试文件的 import 直指 pkg/testkit、调用点一字未改;hub internal/testkit 只剩 Hub 专有的 APIResponse 夹具并补回被 shim 带走的包 doc,pkg/testkit 里指向已删副本的过期注释同步订正(净 −44 行、−1 包) Co-authored-by: Cursor <cursor@vectorcontrol.tech>
|
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 |
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.
做了什么
消融两层纯转发 shim(round-70 过度抽象轴):
edge-server/internal/testkit/eventually.go(25 行,整包消失)WaitFor/Eventually两个函数,函数体各一行原样转给pkg/testkit;0 自有行为、0 测试hub-server/internal/testkit/eventually.go(25 行)resp.go是 Hub 专有的APIResponse夹具(真实共享代码,保留)11 个测试文件只把 import 路径从
<server>/internal/testkit换成pkg/testkit,调用点一字未改(两边包名都叫testkit)。判定标准(本 PR 用的剃刀):1 个真实现 + 1 个 mock 是合理可测性,不算过度抽象;0 行为、0 测试、只把调用原样搬到另一个包的间接层才是。 这两层属于后者——它们存在的唯一理由写在注释里("callers keep their existing testkit.* imports"),即为兼容旧 import 路径而保留的复制层,
pkg/testkit(#1550)落地后就已经是死重量。顺带修的两处手抄分岔(round-69 教训:删了实现却留下指向它的注释):
hub-server/internal/testkit/resp.go:包 doc 原本写在被删的eventually.go里,删完包变成无 doc,已补回并写明该包现在只装 Hub 专有夹具。pkg/testkit/eventually.go:注释声称 "was duplicated verbatim in hub/edge internal/testkit",现副本已不存在,改为陈述现状。净 −44 行、−1 个包(15 files changed, 19 insertions(+), 63 deletions(-))。
证据(本机 huawei-dev 实跑)
覆盖到全部 11 个改过 import 的文件所属包(edge 6 个文件分布在 events/hub/lifecycle/tests;hub 5 个分布在 service/agent、service/contact、service/session、ws)。
edge-server/tests/hub_e2e_test.go与 hubtests/**由go vet ./...保证编译通过(它们需要真实 Hub/PG,属 L1/L2,不在本 PR 的 L0 门禁内跑)。残留引用核查:
git grep "edge-server/internal/testkit"= 0 命中(只剩pkg/testkit注释里已订正的历史说明)。Negative constraints(本 PR 没做也不该做)
pkg/testkit/oidcfixture(169 行,5 个真实消费方,是共享夹具不是间接层)。hub-server/internal/{handler,repository}域子包、没拆edge-server/internal/lifecycle(19k 行是 god type 不是 god package,拆类型属设计项目)。dispatch/dispatchsvc(单向依赖 + 双 doc.go 明写勿合)。