复用已有 GetTier() 返回的 tier ID(free-tier / g1-pro-tier / g1-ultra-tier),通过 TierIDToPlanType 映射为 Free / Pro / Ultra, 在 loadProjectIDWithRetry 中顺带提取并写入 credentials.plan_type; 前端增加 Abnormal 异常套餐红色标记。 Made-with: Cursor
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
//go:build unit
|
|
|
|
package service
|
|
|
|
import "testing"
|
|
|
|
func TestApplyAntigravityPrivacyMode_SetsInMemoryExtra(t *testing.T) {
|
|
account := &Account{}
|
|
|
|
applyAntigravityPrivacyMode(account, AntigravityPrivacySet)
|
|
|
|
if account.Extra == nil {
|
|
t.Fatal("expected account.Extra to be initialized")
|
|
}
|
|
if got := account.Extra["privacy_mode"]; got != AntigravityPrivacySet {
|
|
t.Fatalf("expected privacy_mode %q, got %v", AntigravityPrivacySet, got)
|
|
}
|
|
}
|
|
|
|
func TestApplyAntigravityPrivacyMode_PreservedBySubscriptionResult(t *testing.T) {
|
|
account := &Account{
|
|
Credentials: map[string]any{
|
|
"access_token": "token",
|
|
},
|
|
Extra: map[string]any{
|
|
"existing": "value",
|
|
},
|
|
}
|
|
applyAntigravityPrivacyMode(account, AntigravityPrivacySet)
|
|
|
|
_, extra := applyAntigravitySubscriptionResult(account, AntigravitySubscriptionResult{
|
|
PlanType: "Pro",
|
|
})
|
|
|
|
if got := extra["privacy_mode"]; got != AntigravityPrivacySet {
|
|
t.Fatalf("expected subscription writeback to keep privacy_mode %q, got %v", AntigravityPrivacySet, got)
|
|
}
|
|
if got := extra["existing"]; got != "value" {
|
|
t.Fatalf("expected existing extra fields to be preserved, got %v", got)
|
|
}
|
|
}
|