21 lines
1.1 KiB
TypeScript
21 lines
1.1 KiB
TypeScript
/**
|
|
* google-usage — 429 막힘은 해당 모델에만. 3.6 Flash가 막혀도 Flash-Lite는 계속 구글로 간다.
|
|
*/
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { getConfig } from '../src/config/config';
|
|
import { recordGoogle429, isGoogleNearLimit } from '../src/providers/google-usage';
|
|
|
|
test('한 모델의 429가 다른 구글 모델로 번지지 않는다', () => {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gusage-'));
|
|
(getConfig() as any).getConfigDir = () => dir; // 시험용 임시 폴더로 격리
|
|
const body = 'limit: 20, model: gemini-3.6-flash\nPlease retry in 1h. "quotaId": "GenerateRequestsPerDayPerProjectPerModel-FreeTier"';
|
|
recordGoogle429(body, 'gemini-3.5-flash'); // 별칭: 요청명과 응답명이 다름
|
|
assert.equal(isGoogleNearLimit('gemini-3.6-flash'), true);
|
|
assert.equal(isGoogleNearLimit('gemini-3.5-flash'), true);
|
|
assert.equal(isGoogleNearLimit('gemini-3.5-flash-lite'), false); // 별도 통은 영향 없음
|
|
});
|