mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 06:36:37 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { executeWithRetry } from './table-rows-query'
|
|
|
|
describe('executeWithRetry', () => {
|
|
it('should return the result of the function when successful', async () => {
|
|
const mockFn = vi.fn().mockResolvedValue('success')
|
|
const result = await executeWithRetry(mockFn)
|
|
expect(result).toBe('success')
|
|
expect(mockFn).toHaveBeenCalledTimes(1)
|
|
})
|
|
|
|
it('should retry on 429 errors with exponential backoff', async () => {
|
|
const mockFn = vi
|
|
.fn()
|
|
.mockRejectedValueOnce({ status: 429, headers: { get: () => '1' } })
|
|
.mockRejectedValueOnce({ status: 429, headers: { get: () => '1' } })
|
|
.mockResolvedValue('success')
|
|
|
|
const result = await executeWithRetry(mockFn)
|
|
expect(result).toBe('success')
|
|
expect(mockFn).toHaveBeenCalledTimes(3)
|
|
})
|
|
|
|
it('should throw error after max retries', async () => {
|
|
const mockFn = vi.fn().mockRejectedValue({ status: 429, headers: { get: () => '1' } })
|
|
|
|
await expect(executeWithRetry(mockFn, 2)).rejects.toMatchObject({ status: 429 })
|
|
expect(mockFn).toHaveBeenCalledTimes(3) // Initial attempt + 2 retries
|
|
})
|
|
|
|
it('should throw non-429 errors immediately', async () => {
|
|
const mockFn = vi.fn().mockRejectedValue(new Error('Some other error'))
|
|
|
|
await expect(executeWithRetry(mockFn)).rejects.toThrow('Some other error')
|
|
expect(mockFn).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|