fix: 修复 antigravity UserAgent 重构遗留的编译错误和测试不匹配
- oauth.go: GetUserAgent() 缺少闭合大括号导致语法错误 - client_test.go/oauth_test.go: UserAgent 变量已重构为 GetUserAgent(),更新测试引用 - model_rate_limit_test.go: gemini-3-pro-preview 映射目标已更新为 gemini-3.1-pro-high,同步测试
This commit is contained in:
@@ -49,8 +49,8 @@ func TestNewAPIRequestWithURL_普通请求(t *testing.T) {
|
|||||||
if auth := req.Header.Get("Authorization"); auth != "Bearer test-token" {
|
if auth := req.Header.Get("Authorization"); auth != "Bearer test-token" {
|
||||||
t.Errorf("Authorization 不匹配: got %s", auth)
|
t.Errorf("Authorization 不匹配: got %s", auth)
|
||||||
}
|
}
|
||||||
if ua := req.Header.Get("User-Agent"); ua != UserAgent {
|
if ua := req.Header.Get("User-Agent"); ua != GetUserAgent() {
|
||||||
t.Errorf("User-Agent 不匹配: got %s, want %s", ua, UserAgent)
|
t.Errorf("User-Agent 不匹配: got %s, want %s", ua, GetUserAgent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1191,7 +1191,7 @@ func TestClient_LoadCodeAssist_Success_RealCall(t *testing.T) {
|
|||||||
if ct := r.Header.Get("Content-Type"); ct != "application/json" {
|
if ct := r.Header.Get("Content-Type"); ct != "application/json" {
|
||||||
t.Errorf("Content-Type 不匹配: got %s", ct)
|
t.Errorf("Content-Type 不匹配: got %s", ct)
|
||||||
}
|
}
|
||||||
if ua := r.Header.Get("User-Agent"); ua != UserAgent {
|
if ua := r.Header.Get("User-Agent"); ua != GetUserAgent() {
|
||||||
t.Errorf("User-Agent 不匹配: got %s", ua)
|
t.Errorf("User-Agent 不匹配: got %s", ua)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1380,7 +1380,7 @@ func TestClient_FetchAvailableModels_Success_RealCall(t *testing.T) {
|
|||||||
if ct := r.Header.Get("Content-Type"); ct != "application/json" {
|
if ct := r.Header.Get("Content-Type"); ct != "application/json" {
|
||||||
t.Errorf("Content-Type 不匹配: got %s", ct)
|
t.Errorf("Content-Type 不匹配: got %s", ct)
|
||||||
}
|
}
|
||||||
if ua := r.Header.Get("User-Agent"); ua != UserAgent {
|
if ua := r.Header.Get("User-Agent"); ua != GetUserAgent() {
|
||||||
t.Errorf("User-Agent 不匹配: got %s", ua)
|
t.Errorf("User-Agent 不匹配: got %s", ua)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ func init() {
|
|||||||
// GetUserAgent 返回当前配置的 User-Agent
|
// GetUserAgent 返回当前配置的 User-Agent
|
||||||
func GetUserAgent() string {
|
func GetUserAgent() string {
|
||||||
return fmt.Sprintf("antigravity/%s windows/amd64", defaultUserAgentVersion)
|
return fmt.Sprintf("antigravity/%s windows/amd64", defaultUserAgentVersion)
|
||||||
|
}
|
||||||
|
|
||||||
func getClientSecret() (string, error) {
|
func getClientSecret() (string, error) {
|
||||||
if v := strings.TrimSpace(ClientSecret); v != "" {
|
if v := strings.TrimSpace(ClientSecret); v != "" {
|
||||||
return v, nil
|
return v, nil
|
||||||
|
|||||||
@@ -676,8 +676,8 @@ func TestConstants_值正确(t *testing.T) {
|
|||||||
if RedirectURI != "http://localhost:8085/callback" {
|
if RedirectURI != "http://localhost:8085/callback" {
|
||||||
t.Errorf("RedirectURI 不匹配: got %s", RedirectURI)
|
t.Errorf("RedirectURI 不匹配: got %s", RedirectURI)
|
||||||
}
|
}
|
||||||
if UserAgent != "antigravity/1.15.8 windows/amd64" {
|
if GetUserAgent() != "antigravity/1.84.2 windows/amd64" {
|
||||||
t.Errorf("UserAgent 不匹配: got %s", UserAgent)
|
t.Errorf("UserAgent 不匹配: got %s", GetUserAgent())
|
||||||
}
|
}
|
||||||
if SessionTTL != 30*time.Minute {
|
if SessionTTL != 30*time.Minute {
|
||||||
t.Errorf("SessionTTL 不匹配: got %v", SessionTTL)
|
t.Errorf("SessionTTL 不匹配: got %v", SessionTTL)
|
||||||
|
|||||||
@@ -107,12 +107,12 @@ func TestIsModelRateLimited(t *testing.T) {
|
|||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "antigravity platform - gemini-3-pro-preview mapped to gemini-3-pro-high",
|
name: "antigravity platform - gemini-3-pro-preview mapped to gemini-3.1-pro-high",
|
||||||
account: &Account{
|
account: &Account{
|
||||||
Platform: PlatformAntigravity,
|
Platform: PlatformAntigravity,
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
modelRateLimitsKey: map[string]any{
|
modelRateLimitsKey: map[string]any{
|
||||||
"gemini-3-pro-high": map[string]any{
|
"gemini-3.1-pro-high": map[string]any{
|
||||||
"rate_limit_reset_at": future,
|
"rate_limit_reset_at": future,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user