feat(antigravity): 从 LoadCodeAssist 复用 TierInfo 提取 plan_type
复用已有 GetTier() 返回的 tier ID(free-tier / g1-pro-tier / g1-ultra-tier),通过 TierIDToPlanType 映射为 Free / Pro / Ultra, 在 loadProjectIDWithRetry 中顺带提取并写入 credentials.plan_type; 前端增加 Abnormal 异常套餐红色标记。 Made-with: Cursor
This commit is contained in:
@@ -250,6 +250,27 @@ func TestGetTier_两者都为nil(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTierIDToPlanType(t *testing.T) {
|
||||
tests := []struct {
|
||||
tierID string
|
||||
want string
|
||||
}{
|
||||
{"free-tier", "Free"},
|
||||
{"g1-pro-tier", "Pro"},
|
||||
{"g1-ultra-tier", "Ultra"},
|
||||
{"FREE-TIER", "Free"},
|
||||
{"", "Free"},
|
||||
{"unknown-tier", "unknown-tier"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.tierID, func(t *testing.T) {
|
||||
if got := TierIDToPlanType(tt.tierID); got != tt.want {
|
||||
t.Errorf("TierIDToPlanType(%q) = %q, want %q", tt.tierID, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// NewClient
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -800,6 +821,12 @@ type redirectRoundTripper struct {
|
||||
transport http.RoundTripper
|
||||
}
|
||||
|
||||
type roundTripperFunc func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return f(req)
|
||||
}
|
||||
|
||||
func (rt *redirectRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
originalURL := req.URL.String()
|
||||
for prefix, target := range rt.redirects {
|
||||
@@ -1271,6 +1298,12 @@ func TestClient_LoadCodeAssist_Success_RealCall(t *testing.T) {
|
||||
if reqBody.Metadata.IDEType != "ANTIGRAVITY" {
|
||||
t.Errorf("IDEType 不匹配: got %s, want ANTIGRAVITY", reqBody.Metadata.IDEType)
|
||||
}
|
||||
if strings.TrimSpace(reqBody.Metadata.IDEVersion) == "" {
|
||||
t.Errorf("IDEVersion 不应为空")
|
||||
}
|
||||
if reqBody.Metadata.IDEName != "antigravity" {
|
||||
t.Errorf("IDEName 不匹配: got %s, want antigravity", reqBody.Metadata.IDEName)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user