- server.go: 删 mux.HandleFunc("/api/v1/feedback", api.Feedback) 注册
- core.go: 删 Feedback handler(按 useful 写 useful_count/not_useful_count)
- 回归守卫 server_route_guard_test.go: 断言裸路由不注册 + 4 子路由在
- tests/integration_test.sh: 反馈改走 /api/v1/feedback/useful
- README.md: 裸路由文档改为拆分后 4 子路由
AC2 证伪无调用方:grep 'api/v1/feedback"' 仅命中自身注册行(现已删)。
AC3 退废后 not_useful_count 仅剩 schema/struct 向后兼容声明、[DEPRECATED] IncrementNotUseful(无路由调用)、迁移工具读、注释。
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package api
|
||
|
||
import (
|
||
"os"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
// GA-P0-7 (t_dd64345a):回归守卫 —— 裸路由 /api/v1/feedback 已退役。
|
||
// 它的 handler(core.go Feedback,已删)曾按 useful 布尔写旧字段 not_useful_count
|
||
// (P0-1 t_718d8707 已拆分为 human_not_useful_count / dedup_downweight_count)。
|
||
// 谁若重新注册这个裸路由(旧字段随之复活),本测试必须红。
|
||
func TestNoBareFeedbackRoute(t *testing.T) {
|
||
src, err := os.ReadFile("server.go")
|
||
if err != nil {
|
||
t.Fatalf("read server.go: %v", err)
|
||
}
|
||
s := string(src)
|
||
|
||
// 裸路由注册必须不存在(精确匹配 server.go:385 的旧行)。
|
||
bare := `mux.HandleFunc("/api/v1/feedback", api.Feedback)`
|
||
if strings.Contains(s, bare) {
|
||
t.Fatalf("裸 /api/v1/feedback 路由被重新注册——其 handler 写旧字段 not_useful_count(GA-P0-1);请改用 /api/v1/feedback/{useful,not-useful,deprecate,correct}")
|
||
}
|
||
|
||
// 新拆分后的子路由必须在(反馈统一走它们,写 human_not_useful_count 等新字段)。
|
||
for _, sub := range []string{
|
||
`"/api/v1/feedback/useful"`,
|
||
`"/api/v1/feedback/not-useful"`,
|
||
`"/api/v1/feedback/deprecate"`,
|
||
`"/api/v1/feedback/correct"`,
|
||
} {
|
||
if !strings.Contains(s, sub) {
|
||
t.Fatalf("期望子路由 %s 已注册,但 server.go 中缺失", sub)
|
||
}
|
||
}
|
||
} |