package auth import ( "testing" "time" ) func TestIsAuthBlockedForModel_ClaudeWithCreditsStillBlockedDuringCooldown(t *testing.T) { auth := &Auth{ ID: "ag-1", Provider: "antigravity", ModelStates: map[string]*ModelState{ "claude-sonnet-4-6": { Unavailable: true, NextRetryAfter: time.Now().Add(10 * time.Minute), Quota: QuotaState{ Exceeded: true, NextRecoverAt: time.Now().Add(10 * time.Minute), }, }, }, } SetAntigravityCreditsHint(auth.ID, AntigravityCreditsHint{ Known: true, Available: true, UpdatedAt: time.Now(), }) blocked, reason, _ := isAuthBlockedForModel(auth, "claude-sonnet-4-6", time.Now()) if !blocked || reason != blockReasonCooldown { t.Fatalf("expected auth to be blocked during cooldown even with credits, got blocked=%v reason=%v", blocked, reason) } } func TestIsAuthBlockedForModel_KeepsGeminiBlockedWithoutCreditsBypass(t *testing.T) { auth := &Auth{ ID: "ag-2", Provider: "antigravity", ModelStates: map[string]*ModelState{ "gemini-3-flash": { Unavailable: true, NextRetryAfter: time.Now().Add(10 * time.Minute), Quota: QuotaState{ Exceeded: true, NextRecoverAt: time.Now().Add(10 * time.Minute), }, }, }, } SetAntigravityCreditsHint(auth.ID, AntigravityCreditsHint{ Known: true, Available: true, UpdatedAt: time.Now(), }) blocked, reason, _ := isAuthBlockedForModel(auth, "gemini-3-flash", time.Now()) if !blocked || reason != blockReasonCooldown { t.Fatalf("expected gemini auth to remain blocked, got blocked=%v reason=%v", blocked, reason) } }