feat(v2): add parseConfig with clamped TOP_N and safe defaults
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ff5620c95c
commit
32ebe0d4f2
@@ -0,0 +1,32 @@
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { parseConfig } = require('./config');
|
||||
|
||||
test('valores padrao quando env vazio', () => {
|
||||
const config = parseConfig({});
|
||||
assert.equal(config.aiEnabled, true);
|
||||
assert.equal(config.aiProvider, 'openai');
|
||||
assert.equal(config.candidatePoolSize, 60);
|
||||
assert.equal(config.aiMaxCandidates, 30);
|
||||
assert.equal(config.topN, 10);
|
||||
assert.equal(config.aiConfidenceThreshold, 0.6);
|
||||
assert.equal(config.shadowMode, true);
|
||||
assert.equal(config.devMode, true);
|
||||
});
|
||||
|
||||
test('AI_ENABLED=false desliga a IA', () => {
|
||||
const config = parseConfig({ AI_ENABLED: 'false' });
|
||||
assert.equal(config.aiEnabled, false);
|
||||
});
|
||||
|
||||
test('TOP_N nunca passa de 10 mesmo se configurado maior', () => {
|
||||
const config = parseConfig({ TOP_N: '25' });
|
||||
assert.equal(config.topN, 10);
|
||||
});
|
||||
|
||||
test('overrides numericos sao respeitados', () => {
|
||||
const config = parseConfig({ CANDIDATE_POOL_SIZE: '80', AI_MAX_CANDIDATES: '15', COOLDOWN_DAYS: '2' });
|
||||
assert.equal(config.candidatePoolSize, 80);
|
||||
assert.equal(config.aiMaxCandidates, 15);
|
||||
assert.equal(config.cooldownDays, 2);
|
||||
});
|
||||
Reference in New Issue
Block a user