修复格式问题。
This commit is contained in:
@@ -73,27 +73,27 @@ func GroupFromServiceShallow(g *service.Group) *Group {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &Group{
|
return &Group{
|
||||||
ID: g.ID,
|
ID: g.ID,
|
||||||
Name: g.Name,
|
Name: g.Name,
|
||||||
Description: g.Description,
|
Description: g.Description,
|
||||||
Platform: g.Platform,
|
Platform: g.Platform,
|
||||||
RateMultiplier: g.RateMultiplier,
|
RateMultiplier: g.RateMultiplier,
|
||||||
IsExclusive: g.IsExclusive,
|
IsExclusive: g.IsExclusive,
|
||||||
Status: g.Status,
|
Status: g.Status,
|
||||||
SubscriptionType: g.SubscriptionType,
|
SubscriptionType: g.SubscriptionType,
|
||||||
DailyLimitUSD: g.DailyLimitUSD,
|
DailyLimitUSD: g.DailyLimitUSD,
|
||||||
WeeklyLimitUSD: g.WeeklyLimitUSD,
|
WeeklyLimitUSD: g.WeeklyLimitUSD,
|
||||||
MonthlyLimitUSD: g.MonthlyLimitUSD,
|
MonthlyLimitUSD: g.MonthlyLimitUSD,
|
||||||
ImagePrice1K: g.ImagePrice1K,
|
ImagePrice1K: g.ImagePrice1K,
|
||||||
ImagePrice2K: g.ImagePrice2K,
|
ImagePrice2K: g.ImagePrice2K,
|
||||||
ImagePrice4K: g.ImagePrice4K,
|
ImagePrice4K: g.ImagePrice4K,
|
||||||
ClaudeCodeOnly: g.ClaudeCodeOnly,
|
ClaudeCodeOnly: g.ClaudeCodeOnly,
|
||||||
FallbackGroupID: g.FallbackGroupID,
|
FallbackGroupID: g.FallbackGroupID,
|
||||||
ModelRouting: g.ModelRouting,
|
ModelRouting: g.ModelRouting,
|
||||||
ModelRoutingEnabled: g.ModelRoutingEnabled,
|
ModelRoutingEnabled: g.ModelRoutingEnabled,
|
||||||
CreatedAt: g.CreatedAt,
|
CreatedAt: g.CreatedAt,
|
||||||
UpdatedAt: g.UpdatedAt,
|
UpdatedAt: g.UpdatedAt,
|
||||||
AccountCount: g.AccountCount,
|
AccountCount: g.AccountCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,21 +207,21 @@ func (s *APIKeyService) snapshotFromAPIKey(apiKey *APIKey) *APIKeyAuthSnapshot {
|
|||||||
}
|
}
|
||||||
if apiKey.Group != nil {
|
if apiKey.Group != nil {
|
||||||
snapshot.Group = &APIKeyAuthGroupSnapshot{
|
snapshot.Group = &APIKeyAuthGroupSnapshot{
|
||||||
ID: apiKey.Group.ID,
|
ID: apiKey.Group.ID,
|
||||||
Name: apiKey.Group.Name,
|
Name: apiKey.Group.Name,
|
||||||
Platform: apiKey.Group.Platform,
|
Platform: apiKey.Group.Platform,
|
||||||
Status: apiKey.Group.Status,
|
Status: apiKey.Group.Status,
|
||||||
SubscriptionType: apiKey.Group.SubscriptionType,
|
SubscriptionType: apiKey.Group.SubscriptionType,
|
||||||
RateMultiplier: apiKey.Group.RateMultiplier,
|
RateMultiplier: apiKey.Group.RateMultiplier,
|
||||||
DailyLimitUSD: apiKey.Group.DailyLimitUSD,
|
DailyLimitUSD: apiKey.Group.DailyLimitUSD,
|
||||||
WeeklyLimitUSD: apiKey.Group.WeeklyLimitUSD,
|
WeeklyLimitUSD: apiKey.Group.WeeklyLimitUSD,
|
||||||
MonthlyLimitUSD: apiKey.Group.MonthlyLimitUSD,
|
MonthlyLimitUSD: apiKey.Group.MonthlyLimitUSD,
|
||||||
ImagePrice1K: apiKey.Group.ImagePrice1K,
|
ImagePrice1K: apiKey.Group.ImagePrice1K,
|
||||||
ImagePrice2K: apiKey.Group.ImagePrice2K,
|
ImagePrice2K: apiKey.Group.ImagePrice2K,
|
||||||
ImagePrice4K: apiKey.Group.ImagePrice4K,
|
ImagePrice4K: apiKey.Group.ImagePrice4K,
|
||||||
ClaudeCodeOnly: apiKey.Group.ClaudeCodeOnly,
|
ClaudeCodeOnly: apiKey.Group.ClaudeCodeOnly,
|
||||||
FallbackGroupID: apiKey.Group.FallbackGroupID,
|
FallbackGroupID: apiKey.Group.FallbackGroupID,
|
||||||
ModelRouting: apiKey.Group.ModelRouting,
|
ModelRouting: apiKey.Group.ModelRouting,
|
||||||
ModelRoutingEnabled: apiKey.Group.ModelRoutingEnabled,
|
ModelRoutingEnabled: apiKey.Group.ModelRoutingEnabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,21 +250,21 @@ func (s *APIKeyService) snapshotToAPIKey(key string, snapshot *APIKeyAuthSnapsho
|
|||||||
}
|
}
|
||||||
if snapshot.Group != nil {
|
if snapshot.Group != nil {
|
||||||
apiKey.Group = &Group{
|
apiKey.Group = &Group{
|
||||||
ID: snapshot.Group.ID,
|
ID: snapshot.Group.ID,
|
||||||
Name: snapshot.Group.Name,
|
Name: snapshot.Group.Name,
|
||||||
Platform: snapshot.Group.Platform,
|
Platform: snapshot.Group.Platform,
|
||||||
Status: snapshot.Group.Status,
|
Status: snapshot.Group.Status,
|
||||||
Hydrated: true,
|
Hydrated: true,
|
||||||
SubscriptionType: snapshot.Group.SubscriptionType,
|
SubscriptionType: snapshot.Group.SubscriptionType,
|
||||||
RateMultiplier: snapshot.Group.RateMultiplier,
|
RateMultiplier: snapshot.Group.RateMultiplier,
|
||||||
DailyLimitUSD: snapshot.Group.DailyLimitUSD,
|
DailyLimitUSD: snapshot.Group.DailyLimitUSD,
|
||||||
WeeklyLimitUSD: snapshot.Group.WeeklyLimitUSD,
|
WeeklyLimitUSD: snapshot.Group.WeeklyLimitUSD,
|
||||||
MonthlyLimitUSD: snapshot.Group.MonthlyLimitUSD,
|
MonthlyLimitUSD: snapshot.Group.MonthlyLimitUSD,
|
||||||
ImagePrice1K: snapshot.Group.ImagePrice1K,
|
ImagePrice1K: snapshot.Group.ImagePrice1K,
|
||||||
ImagePrice2K: snapshot.Group.ImagePrice2K,
|
ImagePrice2K: snapshot.Group.ImagePrice2K,
|
||||||
ImagePrice4K: snapshot.Group.ImagePrice4K,
|
ImagePrice4K: snapshot.Group.ImagePrice4K,
|
||||||
ClaudeCodeOnly: snapshot.Group.ClaudeCodeOnly,
|
ClaudeCodeOnly: snapshot.Group.ClaudeCodeOnly,
|
||||||
FallbackGroupID: snapshot.Group.FallbackGroupID,
|
FallbackGroupID: snapshot.Group.FallbackGroupID,
|
||||||
ModelRouting: snapshot.Group.ModelRouting,
|
ModelRouting: snapshot.Group.ModelRouting,
|
||||||
ModelRoutingEnabled: snapshot.Group.ModelRoutingEnabled,
|
ModelRoutingEnabled: snapshot.Group.ModelRoutingEnabled,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,12 +172,12 @@ func TestAPIKeyService_GetByKey_UsesL2Cache(t *testing.T) {
|
|||||||
Concurrency: 3,
|
Concurrency: 3,
|
||||||
},
|
},
|
||||||
Group: &APIKeyAuthGroupSnapshot{
|
Group: &APIKeyAuthGroupSnapshot{
|
||||||
ID: groupID,
|
ID: groupID,
|
||||||
Name: "g",
|
Name: "g",
|
||||||
Platform: PlatformAnthropic,
|
Platform: PlatformAnthropic,
|
||||||
Status: StatusActive,
|
Status: StatusActive,
|
||||||
SubscriptionType: SubscriptionTypeStandard,
|
SubscriptionType: SubscriptionTypeStandard,
|
||||||
RateMultiplier: 1,
|
RateMultiplier: 1,
|
||||||
ModelRoutingEnabled: true,
|
ModelRoutingEnabled: true,
|
||||||
ModelRouting: map[string][]int64{
|
ModelRouting: map[string][]int64{
|
||||||
"claude-opus-*": {1, 2},
|
"claude-opus-*": {1, 2},
|
||||||
|
|||||||
@@ -696,11 +696,11 @@ func TestClaudeTokenProvider_RefreshPreservesExistingCredentials(t *testing.T) {
|
|||||||
Platform: PlatformAnthropic,
|
Platform: PlatformAnthropic,
|
||||||
Type: AccountTypeOAuth,
|
Type: AccountTypeOAuth,
|
||||||
Credentials: map[string]any{
|
Credentials: map[string]any{
|
||||||
"access_token": "old-access-token",
|
"access_token": "old-access-token",
|
||||||
"refresh_token": "old-refresh-token",
|
"refresh_token": "old-refresh-token",
|
||||||
"expires_at": expiresAt,
|
"expires_at": expiresAt,
|
||||||
"custom_field": "should-be-preserved",
|
"custom_field": "should-be-preserved",
|
||||||
"organization": "test-org",
|
"organization": "test-org",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
accountRepo.account = account
|
accountRepo.account = account
|
||||||
|
|||||||
@@ -545,20 +545,20 @@ func TestOpenAITokenProvider_OAuthServiceNotConfigured(t *testing.T) {
|
|||||||
|
|
||||||
func TestOpenAITokenProvider_TTLCalculation(t *testing.T) {
|
func TestOpenAITokenProvider_TTLCalculation(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
expiresIn time.Duration
|
expiresIn time.Duration
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "far_future_expiry",
|
name: "far_future_expiry",
|
||||||
expiresIn: 1 * time.Hour,
|
expiresIn: 1 * time.Hour,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "medium_expiry",
|
name: "medium_expiry",
|
||||||
expiresIn: 10 * time.Minute,
|
expiresIn: 10 * time.Minute,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "near_expiry",
|
name: "near_expiry",
|
||||||
expiresIn: 6 * time.Minute,
|
expiresIn: 6 * time.Minute,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ func TestCompositeTokenCacheInvalidator_SkipNonOAuth(t *testing.T) {
|
|||||||
invalidator := NewCompositeTokenCacheInvalidator(cache)
|
invalidator := NewCompositeTokenCacheInvalidator(cache)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
account *Account
|
account *Account
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "gemini_api_key",
|
name: "gemini_api_key",
|
||||||
@@ -210,8 +210,8 @@ func TestCompositeTokenCacheInvalidator_DeleteError(t *testing.T) {
|
|||||||
invalidator := NewCompositeTokenCacheInvalidator(cache)
|
invalidator := NewCompositeTokenCacheInvalidator(cache)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
account *Account
|
account *Account
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "openai_delete_error",
|
name: "openai_delete_error",
|
||||||
|
|||||||
@@ -276,9 +276,9 @@ func TestTokenRefreshService_RefreshWithRetry_RefreshFailed(t *testing.T) {
|
|||||||
|
|
||||||
err := service.refreshWithRetry(context.Background(), account, refresher)
|
err := service.refreshWithRetry(context.Background(), account, refresher)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, 0, repo.updateCalls) // 刷新失败不应更新
|
require.Equal(t, 0, repo.updateCalls) // 刷新失败不应更新
|
||||||
require.Equal(t, 0, invalidator.calls) // 刷新失败不应触发缓存失效
|
require.Equal(t, 0, invalidator.calls) // 刷新失败不应触发缓存失效
|
||||||
require.Equal(t, 1, repo.setErrorCalls) // 应设置错误状态
|
require.Equal(t, 1, repo.setErrorCalls) // 应设置错误状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestTokenRefreshService_RefreshWithRetry_AntigravityRefreshFailed 测试 Antigravity 刷新失败不设置错误状态
|
// TestTokenRefreshService_RefreshWithRetry_AntigravityRefreshFailed 测试 Antigravity 刷新失败不设置错误状态
|
||||||
|
|||||||
Reference in New Issue
Block a user