Files
sub2api/backend/internal/service/group_profit_platform_test.go
T
李建琦 6d655c9903
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
Sub2API v1.0 - AI API 网关(二开初始版本,基于上游 Wei-Shaw/sub2api)
2026-08-21 18:30:13 +08:00

21 lines
1.0 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 service
import "testing"
// TestNormalizeGroupPlatformDefaultsToAnthropic 钉死创建分组时省略 platform 的
// 归一化结果:handler 的利润控制预校验与 CreateGroup 落库共用这个函数,
// 两边一旦漂移,「省略 platform + profit_control_enabled=true」的创建请求
// 会被 handler 以「平台不支持」400 掉,而该分组本会建成受支持的 anthropic。
func TestNormalizeGroupPlatformDefaultsToAnthropic(t *testing.T) {
if got := NormalizeGroupPlatform(""); got != PlatformAnthropic {
t.Fatalf("空 platform 应归一化为 %sgot %s", PlatformAnthropic, got)
}
if got := NormalizeGroupPlatform(PlatformOpenAI); got != PlatformOpenAI {
t.Fatalf("显式 platform 不应被改写,got %s", got)
}
// 归一化后的默认平台必须真的支持利润控制,否则预校验仍会误拒。
if err := ValidateProfitControlConfig(NormalizeGroupPlatform(""), true, 0.3, 0.05); err != nil {
t.Fatalf("省略 platform 且启用利润控制不应被预校验拒绝: %v", err)
}
}