chore: establish learning module baseline
This commit is contained in:
23
OpenMAIC/tests/setup-env.ts
Normal file
23
OpenMAIC/tests/setup-env.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Load .env.local before tests so API keys are available.
|
||||
*/
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
|
||||
const envPath = resolve(__dirname, '..', '.env.local');
|
||||
try {
|
||||
const content = readFileSync(envPath, 'utf-8');
|
||||
for (const line of content.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith('#')) continue;
|
||||
const eqIdx = trimmed.indexOf('=');
|
||||
if (eqIdx < 0) continue;
|
||||
const key = trimmed.slice(0, eqIdx).trim();
|
||||
const value = trimmed.slice(eqIdx + 1).trim();
|
||||
if (!process.env[key]) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// .env.local not found, skip
|
||||
}
|
||||
Reference in New Issue
Block a user