mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-15 04:14:46 +08:00
fix: 修复 Antigravity 账号 intercept_warmup_requests 配置无法保存
提取 applyInterceptWarmup 纯函数统一所有调用点: - 修复 upstream 创建时遗漏写入 intercept_warmup_requests - 修复 apikey 编辑时缺少 else 清除逻辑 - 添加前后端单元测试 - 修复 vitest.config.ts mergeConfig 兼容性问题
This commit is contained in:
66
backend/internal/service/account_intercept_warmup_test.go
Normal file
66
backend/internal/service/account_intercept_warmup_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
//go:build unit
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestAccount_IsInterceptWarmupEnabled(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
credentials map[string]any
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "nil credentials",
|
||||
credentials: nil,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "empty map",
|
||||
credentials: map[string]any{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "field not present",
|
||||
credentials: map[string]any{"access_token": "tok"},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "field is true",
|
||||
credentials: map[string]any{"intercept_warmup_requests": true},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "field is false",
|
||||
credentials: map[string]any{"intercept_warmup_requests": false},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "field is string true",
|
||||
credentials: map[string]any{"intercept_warmup_requests": "true"},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "field is int 1",
|
||||
credentials: map[string]any{"intercept_warmup_requests": 1},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "field is nil",
|
||||
credentials: map[string]any{"intercept_warmup_requests": nil},
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &Account{Credentials: tt.credentials}
|
||||
result := a.IsInterceptWarmupEnabled()
|
||||
require.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user