mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 15:06:36 +00:00
fix: sync remaining test expectations for Sonnet 4.5 → 4.6 migration
Update model mapping tests, rate limit pre-check tests, thinking suffix tests, and whitelist tests to reflect the new default mapping and simplified applyThinkingModelSuffix behavior.
This commit is contained in:
1 parent
8b31e00a14
commit
7c0de8b1a1
5 files changed
+17
-16
No files matched your search
@@ -69,10 +69,10 @@ func TestAntigravityGatewayService_GetMappedModel(t *testing.T) {
|
|||||||
expected: "claude-sonnet-4-6",
|
expected: "claude-sonnet-4-6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "默认映射 - claude-sonnet-4-5-20250929 → claude-sonnet-4-5",
|
name: "默认映射 - claude-sonnet-4-5-20250929 → claude-sonnet-4-6",
|
||||||
requestedModel: "claude-sonnet-4-5-20250929",
|
requestedModel: "claude-sonnet-4-5-20250929",
|
||||||
accountMapping: nil,
|
accountMapping: nil,
|
||||||
expected: "claude-sonnet-4-5",
|
expected: "claude-sonnet-4-6",
|
||||||
},
|
},
|
||||||
|
|
||||||
// 3. 默认映射中的透传(映射到自己)
|
// 3. 默认映射中的透传(映射到自己)
|
||||||
@@ -83,10 +83,10 @@ func TestAntigravityGatewayService_GetMappedModel(t *testing.T) {
|
|||||||
expected: "claude-sonnet-4-6",
|
expected: "claude-sonnet-4-6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "默认映射透传 - claude-sonnet-4-5",
|
name: "默认映射 - claude-sonnet-4-5 → claude-sonnet-4-6",
|
||||||
requestedModel: "claude-sonnet-4-5",
|
requestedModel: "claude-sonnet-4-5",
|
||||||
accountMapping: nil,
|
accountMapping: nil,
|
||||||
expected: "claude-sonnet-4-5",
|
expected: "claude-sonnet-4-6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "默认映射透传 - claude-opus-4-6-thinking",
|
name: "默认映射透传 - claude-opus-4-6-thinking",
|
||||||
@@ -95,10 +95,10 @@ func TestAntigravityGatewayService_GetMappedModel(t *testing.T) {
|
|||||||
expected: "claude-opus-4-6-thinking",
|
expected: "claude-opus-4-6-thinking",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "默认映射透传 - claude-sonnet-4-5-thinking",
|
name: "默认映射 - claude-sonnet-4-5-thinking → claude-sonnet-4-6",
|
||||||
requestedModel: "claude-sonnet-4-5-thinking",
|
requestedModel: "claude-sonnet-4-5-thinking",
|
||||||
accountMapping: nil,
|
accountMapping: nil,
|
||||||
expected: "claude-sonnet-4-5-thinking",
|
expected: "claude-sonnet-4-6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "默认映射透传 - gemini-2.5-flash",
|
name: "默认映射透传 - gemini-2.5-flash",
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ func TestHandleUpstreamError_429_NonModelRateLimit(t *testing.T) {
|
|||||||
// 但 429 兜底逻辑会使用 requestedModel 设置模型级限流
|
// 但 429 兜底逻辑会使用 requestedModel 设置模型级限流
|
||||||
require.Nil(t, result)
|
require.Nil(t, result)
|
||||||
require.Len(t, repo.modelRateLimitCalls, 1)
|
require.Len(t, repo.modelRateLimitCalls, 1)
|
||||||
require.Equal(t, "claude-sonnet-4-5", repo.modelRateLimitCalls[0].modelKey)
|
require.Equal(t, "claude-sonnet-4-6", repo.modelRateLimitCalls[0].modelKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestHandleUpstreamError_429_NonModelRateLimit_UsesMappedModelKey 测试 429 非模型限流场景
|
// TestHandleUpstreamError_429_NonModelRateLimit_UsesMappedModelKey 测试 429 非模型限流场景
|
||||||
@@ -831,7 +831,7 @@ func TestAntigravityRetryLoop_PreCheck_SwitchesWhenRateLimited(t *testing.T) {
|
|||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
modelRateLimitsKey: map[string]any{
|
modelRateLimitsKey: map[string]any{
|
||||||
"claude-sonnet-4-5": map[string]any{
|
"claude-sonnet-4-6": map[string]any{
|
||||||
"rate_limit_reset_at": time.Now().Add(2 * time.Second).Format(time.RFC3339),
|
"rate_limit_reset_at": time.Now().Add(2 * time.Second).Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -874,7 +874,7 @@ func TestAntigravityRetryLoop_PreCheck_SwitchesWhenRemainingLong(t *testing.T) {
|
|||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
modelRateLimitsKey: map[string]any{
|
modelRateLimitsKey: map[string]any{
|
||||||
"claude-sonnet-4-5": map[string]any{
|
"claude-sonnet-4-6": map[string]any{
|
||||||
"rate_limit_reset_at": time.Now().Add(11 * time.Second).Format(time.RFC3339),
|
"rate_limit_reset_at": time.Now().Add(11 * time.Second).Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ func TestAntigravityRetryLoop_PreCheck_SingleAccountRetry_SkipsRateLimit(t *test
|
|||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
modelRateLimitsKey: map[string]any{
|
modelRateLimitsKey: map[string]any{
|
||||||
"claude-sonnet-4-5": map[string]any{
|
"claude-sonnet-4-6": map[string]any{
|
||||||
"rate_limit_reset_at": time.Now().Add(30 * time.Second).Format(time.RFC3339),
|
"rate_limit_reset_at": time.Now().Add(30 * time.Second).Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -733,7 +733,7 @@ func TestAntigravityRetryLoop_PreCheck_NoSingleAccountRetry_SwitchesOnRateLimit(
|
|||||||
Concurrency: 1,
|
Concurrency: 1,
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
modelRateLimitsKey: map[string]any{
|
modelRateLimitsKey: map[string]any{
|
||||||
"claude-sonnet-4-5": map[string]any{
|
"claude-sonnet-4-6": map[string]any{
|
||||||
"rate_limit_reset_at": time.Now().Add(30 * time.Second).Format(time.RFC3339),
|
"rate_limit_reset_at": time.Now().Add(30 * time.Second).Format(time.RFC3339),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ func TestApplyThinkingModelSuffix(t *testing.T) {
|
|||||||
expected: "claude-opus-4-6-thinking",
|
expected: "claude-opus-4-6-thinking",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Thinking 开启 + claude-sonnet-4-5:自动添加后缀
|
// Thinking 开启 + claude-sonnet-4-5:Sonnet 4.5 已统一映射到 4.6,不再特殊处理
|
||||||
{
|
{
|
||||||
name: "thinking enabled - claude-sonnet-4-5 becomes thinking version",
|
name: "thinking enabled - claude-sonnet-4-5 unchanged (mapped to 4.6 elsewhere)",
|
||||||
mappedModel: "claude-sonnet-4-5",
|
mappedModel: "claude-sonnet-4-5",
|
||||||
thinkingEnabled: true,
|
thinkingEnabled: true,
|
||||||
expected: "claude-sonnet-4-5-thinking",
|
expected: "claude-sonnet-4-5",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Thinking 开启 + 其他模型:保持原样
|
// Thinking 开启 + 其他模型:保持原样
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ func TestGatewayService_isModelSupportedByAccountWithContext_ThinkingMode(t *tes
|
|||||||
expected: false,
|
expected: false,
|
||||||
},
|
},
|
||||||
// 场景 3: 配置 claude-sonnet-4-5(非 thinking),请求 claude-sonnet-4-5 + thinking=true
|
// 场景 3: 配置 claude-sonnet-4-5(非 thinking),请求 claude-sonnet-4-5 + thinking=true
|
||||||
// 最终模型名 = claude-sonnet-4-5-thinking,不在 mapping 中,应该不匹配
|
// applyThinkingModelSuffix 已简化为直通,不再添加 -thinking 后缀
|
||||||
|
// 最终模型名仍为 claude-sonnet-4-5,在 mapping 中 → 返回 true
|
||||||
{
|
{
|
||||||
name: "thinking_enabled_no_match_non_thinking_mapping",
|
name: "thinking_enabled_no_match_non_thinking_mapping",
|
||||||
modelMapping: map[string]any{
|
modelMapping: map[string]any{
|
||||||
@@ -111,7 +112,7 @@ func TestGatewayService_isModelSupportedByAccountWithContext_ThinkingMode(t *tes
|
|||||||
},
|
},
|
||||||
requestedModel: "claude-sonnet-4-5",
|
requestedModel: "claude-sonnet-4-5",
|
||||||
thinkingEnabled: true,
|
thinkingEnabled: true,
|
||||||
expected: false,
|
expected: true,
|
||||||
},
|
},
|
||||||
// 场景 4: 配置两种模型,请求 claude-sonnet-4-5 + thinking=true,应该匹配 thinking 版本
|
// 场景 4: 配置两种模型,请求 claude-sonnet-4-5 + thinking=true,应该匹配 thinking 版本
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user