(data: Partial<ModelStats> = {})
| 4 | import { randomUUID } from 'crypto'; |
| 5 | |
| 6 | export async function insertTestModelStats(data: Partial<ModelStats> = {}): Promise<ModelStats> { |
| 7 | const randomSuffix = Math.random().toString(36).substring(2, 8); |
| 8 | const now = new Date().toISOString(); |
| 9 | |
| 10 | const testData = { |
| 11 | id: data.id || randomUUID(), |
| 12 | openrouterId: data.openrouterId || `openrouter/test-model-${randomSuffix}`, |
| 13 | slug: data.slug || `test-slug-${randomSuffix}`, |
| 14 | name: data.name || 'Test Model', |
| 15 | isActive: data.isActive ?? true, |
| 16 | openrouterData: data.openrouterData ?? { |
| 17 | id: data.openrouterId || `openrouter/test-model-${randomSuffix}`, |
| 18 | name: data.name || 'Test Model', |
| 19 | created: Date.now(), |
| 20 | description: 'Test model for testing purposes', |
| 21 | context_length: 128000, |
| 22 | pricing: { |
| 23 | prompt: '0.000003', |
| 24 | completion: '0.000015', |
| 25 | request: '0', |
| 26 | image: '0', |
| 27 | }, |
| 28 | top_provider: { |
| 29 | context_length: 128000, |
| 30 | max_completion_tokens: 4096, |
| 31 | is_moderated: false, |
| 32 | }, |
| 33 | per_request_limits: null, |
| 34 | }, |
| 35 | benchmarks: data.benchmarks ?? null, |
| 36 | chartData: data.chartData ?? null, |
| 37 | aaSlug: data.aaSlug ?? null, |
| 38 | codingIndex: data.codingIndex ?? null, |
| 39 | speedTokensPerSec: data.speedTokensPerSec ?? null, |
| 40 | releaseDate: data.releaseDate ?? null, |
| 41 | createdAt: data.createdAt || now, |
| 42 | updatedAt: data.updatedAt || now, |
| 43 | }; |
| 44 | |
| 45 | const result = await db |
| 46 | .insert(modelStats) |
| 47 | .values(testData as ModelStats) |
| 48 | .returning(); |
| 49 | return result[0]; |
| 50 | } |
no test coverage detected