refactor: remove unused IsAntigravityModelSupported function and its tests
This commit is contained in:
@@ -8,49 +8,6 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsAntigravityModelSupported(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
model string
|
|
||||||
expected bool
|
|
||||||
}{
|
|
||||||
// 在默认映射中的模型(支持)
|
|
||||||
{"默认映射 - claude-sonnet-4-5", "claude-sonnet-4-5", true},
|
|
||||||
{"默认映射 - claude-opus-4-6-thinking", "claude-opus-4-6-thinking", true},
|
|
||||||
{"默认映射 - claude-opus-4-6", "claude-opus-4-6", true},
|
|
||||||
{"默认映射 - claude-opus-4-5-thinking", "claude-opus-4-5-thinking", true},
|
|
||||||
{"默认映射 - claude-sonnet-4-5-thinking", "claude-sonnet-4-5-thinking", true},
|
|
||||||
{"默认映射 - gemini-2.5-flash", "gemini-2.5-flash", true},
|
|
||||||
{"默认映射 - gemini-2.5-flash-lite", "gemini-2.5-flash-lite", true},
|
|
||||||
{"默认映射 - gemini-3-pro-high", "gemini-3-pro-high", true},
|
|
||||||
{"默认映射 - claude-haiku-4-5", "claude-haiku-4-5", true},
|
|
||||||
|
|
||||||
// 不在默认映射中的模型(不支持)
|
|
||||||
{"未配置 - claude-3-5-sonnet-20241022", "claude-3-5-sonnet-20241022", false},
|
|
||||||
{"未配置 - claude-3-5-sonnet-20240620", "claude-3-5-sonnet-20240620", false},
|
|
||||||
{"未配置 - claude-3-haiku-20240307", "claude-3-haiku-20240307", false},
|
|
||||||
{"未配置 - gemini-unknown-model", "gemini-unknown-model", false},
|
|
||||||
{"未配置 - gemini-future-version", "gemini-future-version", false},
|
|
||||||
{"未配置 - claude-unknown-model", "claude-unknown-model", false},
|
|
||||||
{"未配置 - claude-3-opus-20240229", "claude-3-opus-20240229", false},
|
|
||||||
{"未配置 - claude-future-version", "claude-future-version", false},
|
|
||||||
|
|
||||||
// 非 Claude/Gemini 模型(不支持)
|
|
||||||
{"不支持 - gpt-4", "gpt-4", false},
|
|
||||||
{"不支持 - gpt-4o", "gpt-4o", false},
|
|
||||||
{"不支持 - llama-3", "llama-3", false},
|
|
||||||
{"不支持 - mistral-7b", "mistral-7b", false},
|
|
||||||
{"不支持 - 空字符串", "", false},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
got := IsAntigravityModelSupported(tt.model)
|
|
||||||
require.Equal(t, tt.expected, got, "model: %s", tt.model)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAntigravityGatewayService_GetMappedModel(t *testing.T) {
|
func TestAntigravityGatewayService_GetMappedModel(t *testing.T) {
|
||||||
svc := &AntigravityGatewayService{}
|
svc := &AntigravityGatewayService{}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Wei-Shaw/sub2api/internal/config"
|
"github.com/Wei-Shaw/sub2api/internal/config"
|
||||||
"github.com/Wei-Shaw/sub2api/internal/domain"
|
|
||||||
"github.com/Wei-Shaw/sub2api/internal/pkg/claude"
|
"github.com/Wei-Shaw/sub2api/internal/pkg/claude"
|
||||||
"github.com/Wei-Shaw/sub2api/internal/pkg/ctxkey"
|
"github.com/Wei-Shaw/sub2api/internal/pkg/ctxkey"
|
||||||
"github.com/Wei-Shaw/sub2api/internal/util/responseheaders"
|
"github.com/Wei-Shaw/sub2api/internal/util/responseheaders"
|
||||||
@@ -2617,13 +2616,6 @@ func (s *GatewayService) isModelSupportedByAccount(account *Account, requestedMo
|
|||||||
return account.IsModelSupported(requestedModel)
|
return account.IsModelSupported(requestedModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAntigravityModelSupported 检查 Antigravity 平台是否支持指定模型
|
|
||||||
// 只有在默认映射(DefaultAntigravityModelMapping)中配置的模型才被支持
|
|
||||||
func IsAntigravityModelSupported(requestedModel string) bool {
|
|
||||||
// 检查是否在默认映射的 key 中
|
|
||||||
_, exists := domain.DefaultAntigravityModelMapping[requestedModel]
|
|
||||||
return exists
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAccessToken 获取账号凭证
|
// GetAccessToken 获取账号凭证
|
||||||
func (s *GatewayService) GetAccessToken(ctx context.Context, account *Account) (string, string, error) {
|
func (s *GatewayService) GetAccessToken(ctx context.Context, account *Account) (string, string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user