Files
tokens-reef/backend/internal/server/routes/admin_routes_test.go
pham 0e057904e6
Some checks failed
CI / test (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled
refactor: 彻底移除 Sora 视频生成模块(全栈清理)
## 后端变更
- 删除 21 个 sora_*.go 服务文件(service/handler/repository/routes)
- 删除 Sora 相关 migration 文件(046/047/063/090)
- 清理 config 中的 sora_* 配置项和平台常量
- 清理 wire 依赖注入中的 Sora 组件
- 修复 wire_gen.go 语法错误(缺少逗号和闭合括号)
- 移除 go.mod 中的 go-sora2api 依赖
- 更新 ent schema usage_log.go 注释

## 前端变更
- 删除 SoraView、SoraAdminView 及 8 个 Sora 子组件
- 删除 sora API 层和路由配置
- 清理 UserEditModal 中的 Sora 存储配额 UI
- 清理 types/index.ts 中 Sora 相关类型定义
- 清理 stores/app.ts 默认配置
- 清理 i18n 翻译文件 en.ts/zh.ts (~110 行)
- 更新相关测试文件

## 文档更新
- README.md / README_CN.md / README_JA.md: 移除 Sora 状态说明和配置段落
- PROJECT_DIFF.md: 移除 Sora 相关差异描述

## 验证结果
-  Go 编译通过 (go build ./...)
-  TypeScript 类型检查通过 (vue-tsc --noEmit)
-  后端测试全通过 (0 failures)
-  前端测试全通过 (59 files, 329 tests, 0 failures)
-  前端生产构建成功 (23.81s)
2026-05-10 14:15:45 +08:00

52 lines
1.5 KiB
Go

package routes
import (
"testing"
"github.com/Wei-Shaw/sub2api/internal/handler"
"github.com/Wei-Shaw/sub2api/internal/server/middleware"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/require"
)
func TestRegisterAdminRoutes_OmitsDeprecatedMockEndpoints(t *testing.T) {
gin.SetMode(gin.TestMode)
engine := gin.New()
v1 := engine.Group("/api/v1")
adminAuth := middleware.AdminAuthMiddleware(func(c *gin.Context) {
c.Next()
})
RegisterAdminRoutes(v1, &handler.Handlers{
Admin: &handler.AdminHandlers{},
}, adminAuth)
routesByMethodAndPath := make(map[string]struct{})
for _, route := range engine.Routes() {
routesByMethodAndPath[route.Method+" "+route.Path] = struct{}{}
}
deprecatedRoutes := []string{
"GET /api/v1/admin/dashboard/realtime",
"GET /api/v1/admin/dashboard/stats",
"GET /api/v1/admin/dashboard/trend",
"GET /api/v1/admin/dashboard/groups",
"GET /api/v1/admin/dashboard/api-keys-trend",
"POST /api/v1/admin/dashboard/api-keys-usage",
"POST /api/v1/admin/dashboard/aggregation/backfill",
"GET /api/v1/admin/groups/:id/stats",
"GET /api/v1/admin/users/:id/usage",
"GET /api/v1/admin/proxies/:id/stats",
"GET /api/v1/admin/redeem-codes/stats",
"GET /api/v1/admin/data-management/agent/health",
"GET /api/v1/admin/data-management/config",
"POST /api/v1/admin/data-management/backups",
}
for _, route := range deprecatedRoutes {
_, exists := routesByMethodAndPath[route]
require.Falsef(t, exists, "deprecated mock route should not be registered: %s", route)
}
}