package growthreport import ( "context" "errors" "testing" "time" ) func TestCoordinatorFallsBackToBoundedProcessCounters(t *testing.T) { t.Parallel() coordinator := NewCoordinator(nil, CoordinatorConfig{CreatePerMinute: 2, UncachedPerDay: 1, DailyRequests: 1, DailyTokens: 1600, MaxConcurrent: 1}) now := time.Date(2026, 8, 21, 0, 0, 0, 0, time.UTC) if err := coordinator.AllowCreate(context.Background(), 7, now); err != nil { t.Fatal(err) } if err := coordinator.AllowCreate(context.Background(), 7, now); err != nil { t.Fatal(err) } if err := coordinator.AllowCreate(context.Background(), 7, now); !errors.Is(err, ErrRateLimited) { t.Fatalf("third request error=%v", err) } if err := coordinator.ReserveBudget(context.Background(), MaxProviderRequests, 1600, now); !errors.Is(err, ErrBudgetExhausted) { t.Fatalf("budget without Redis error=%v", err) } }