refactor(*): 稳定期治理 - 收敛核心架构、错误语义并修复跨项目数据竞态

This commit is contained in:
ddCat
2026-09-09 22:02:10 +08:00
parent bacd502f5c
commit b5f3413ded
298 changed files with 12681 additions and 26428 deletions

View File

@@ -0,0 +1,42 @@
package handler
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"infinite-canvas/backend/internal/service"
"github.com/gin-gonic/gin"
)
func TestRegisterCanvasAPIExposesOpenAPIAndProjects(t *testing.T) {
gin.SetMode(gin.TestMode)
router := gin.New()
RegisterCanvasAPI(router.Group("/api"), &service.Service{})
wanted := map[string]bool{
"GET /api/openapi.yaml": false,
"GET /api/projects": false,
"POST /api/tasks": false,
"GET /api/resources": false,
}
for _, route := range router.Routes() {
key := route.Method + " " + route.Path
if _, exists := wanted[key]; exists {
wanted[key] = true
}
}
for route, found := range wanted {
if !found {
t.Errorf("route %s is not registered", route)
}
}
recorder := httptest.NewRecorder()
router.ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, "/api/openapi.yaml", nil))
if recorder.Code != http.StatusOK || !strings.Contains(recorder.Body.String(), "openapi: 3.0.3") || !strings.Contains(recorder.Body.String(), "url: /api") {
t.Fatalf("openapi.yaml status=%d body=%s", recorder.Code, recorder.Body.String())
}
}