Files
ai_academy/internal/router/background_routes_test.go
T
runny 9058149576
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
refactor: 项目更名 WeKnora → Academy
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
2026-11-13 20:52:51 +08:00

41 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package router registers the HTTP API, including background-work routes.
package router
import (
"testing"
"academy/internal/config"
"academy/internal/handler"
sessionhandler "academy/internal/handler/session"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/require"
)
// registerRoutesForTest builds the smallest router that exercises session
// registration. Tenant is set so a nil config does not log a startup error.
func registerRoutesForTest(t *testing.T) *gin.Engine {
t.Helper()
gin.SetMode(gin.TestMode)
g := &rbacGuards{cfg: &config.Config{Tenant: &config.TenantConfig{}}}
engine := gin.New()
RegisterSessionRoutes(engine.Group("/api/v1"), &sessionhandler.Handler{}, &handler.MessageSuggestionHandler{}, g)
return engine
}
// Gin 同一 verb 的通配符名必须一致:GET 树已用 :id,POST 树用 :session_id。
func TestBackgroundWorkRoutesRegisterWithoutWildcardConflict(t *testing.T) {
var engine *gin.Engine
require.NotPanics(t, func() {
engine = registerRoutesForTest(t) // 构建最小 RouterGroup 并调用 RegisterSessionRoutes;
// 覆盖点是“注册不 panic”。参数解析由 handler 测试负责。
})
found := map[string]bool{}
for _, route := range engine.Routes() {
found[route.Method+" "+route.Path] = true
}
require.True(t, found["GET /api/v1/sessions/:id/background-work"])
require.True(t, found["GET /api/v1/sessions/:id/background-work/:work_id"])
require.True(t, found["POST /api/v1/sessions/:session_id/background-work/:work_id/cancel"])
require.False(t, found["GET /api/v1/sessions/:session_id/background-work"])
}