refactor(*): 平台架构 - 拆分后端领域模块并同步插件协议与模型能力

This commit is contained in:
ddCat
2026-09-11 14:02:49 +08:00
parent 0945115e53
commit 7ce967df0f
644 changed files with 62731 additions and 2320 deletions

View File

@@ -0,0 +1,26 @@
package app
import (
"context"
"infinite-canvas/backend/internal/platform"
"testing"
"time"
)
func TestRequestRetryAfterMatchesWindow(t *testing.T) {
s := &Service{coordinator: platform.NewCoordinatorWithRedis(nil, "registration-test")}
ctx := context.Background()
if ok, err := s.AllowRequest(ctx, "email-code:test", 1, time.Hour); err != nil || !ok {
t.Fatal(err)
}
if ok, _ := s.AllowRequest(ctx, "email-code:test", 1, time.Hour); ok {
t.Fatal("limit bypassed")
}
wait := s.RequestRetryAfter(ctx, "email-code:test", time.Hour)
if wait < 59*time.Minute || wait > time.Hour {
t.Fatalf("wrong wait: %v", wait)
}
if s.coordinator.LocalRateCount() != 1 {
t.Fatal("rejection consumed quota")
}
}