All checks were successful
CD / Build and push images (push) Successful in 2m35s
CD / Deploy to Test (push) Successful in 8s
CI / Lint, typecheck, test (push) Successful in 3m8s
CI / Build container images (push) Has been skipped
CD / Smoke tests against Test (push) Successful in 1m9s
CD / Promote to Int (push) Successful in 9s
CI / Auth e2e pack (push) Successful in 4m52s
CI / Import/export fidelity gate (push) Successful in 46s
main.ts parsed process.env raw, so the compose passthroughs (SETUP_DEFAULT_LOCALE: "") failed the enum parse and crash-looped the Test api. Route main.ts through the same loadApiEnv as AppConfig, which overlays the secret store and drops empty strings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, it } from 'vitest';
|
|
|
|
import { loadApiEnv } from './app-config.service';
|
|
|
|
/**
|
|
* Regression for the Test-stage boot crash after #80: compose passes
|
|
* optional variables as empty strings (`SETUP_DEFAULT_LOCALE: ${…:-}`),
|
|
* and a raw parse of process.env fails on enum fields. loadApiEnv must
|
|
* treat them as unset — in main.ts exactly like in AppConfig.
|
|
*/
|
|
describe('loadApiEnv', () => {
|
|
const touched = [
|
|
'SETUP_DEFAULT_LOCALE',
|
|
'SETUP_REGISTRATION_MODE',
|
|
'SMTP_HOST',
|
|
'SMTP_PORT',
|
|
'SECRETS_FILE',
|
|
'DATABASE_URL',
|
|
] as const;
|
|
const saved = Object.fromEntries(touched.map((key) => [key, process.env[key]]));
|
|
|
|
afterEach(() => {
|
|
for (const key of touched) {
|
|
if (saved[key] === undefined) delete process.env[key];
|
|
else process.env[key] = saved[key];
|
|
}
|
|
});
|
|
|
|
it('treats compose-passed empty strings as unset', () => {
|
|
process.env.DATABASE_URL = 'postgresql://user:pass@localhost:5432/db';
|
|
process.env.SETUP_DEFAULT_LOCALE = '';
|
|
process.env.SETUP_REGISTRATION_MODE = '';
|
|
process.env.SMTP_HOST = '';
|
|
process.env.SMTP_PORT = '';
|
|
process.env.SECRETS_FILE = '';
|
|
|
|
const env = loadApiEnv();
|
|
expect(env.SETUP_DEFAULT_LOCALE).toBeUndefined();
|
|
expect(env.SETUP_REGISTRATION_MODE).toBeUndefined();
|
|
expect(env.SMTP_HOST).toBe('localhost'); // schema default, not ""
|
|
expect(env.SMTP_PORT).toBe(1025);
|
|
expect(env.SECRETS_FILE).toBe('./data/secrets.env');
|
|
});
|
|
});
|