test: update suites locked to the old direct process.env wiring for the adapter (E00-S04-T04)

This commit is contained in:
implementer
2026-08-30 04:17:22 +00:00
parent 20173a8241
commit 3214807c9d
4 changed files with 79 additions and 44 deletions
+17 -10
View File
@@ -159,8 +159,8 @@ function assertServerSource(src) {
// package's scrubber before it reaches stdout/stderr.
assert.match(
src,
/import \{ assertValidConfig \} from '@personal-blog\/config'/,
'the server must import the startup validation entry point from the config package',
/import \{ loadConfigFromEnv \} from '@personal-blog\/config'/,
'the server must import the environment adapter (loadConfigFromEnv) from the config package',
);
assert.match(
src,
@@ -188,12 +188,13 @@ function assertServerSource(src) {
'error lines must be written to stderr',
);
// The wiring — the server keeps its validated config, creates the logger
// with it and logs the resolved configuration redacted.
// The wiring — the server keeps its validated config (loaded through the
// environment adapter, E00-S04-T04), creates the logger with it and logs
// the resolved configuration redacted.
assert.match(
src,
/const config = assertValidConfig\(\{/,
'the server must keep its validated configuration (const config = assertValidConfig(...))',
/const config = loadConfigFromEnv\(\);/,
'the server must keep its validated configuration (const config = loadConfigFromEnv(), E00-S04-T04)',
);
assert.match(
src,
@@ -215,13 +216,19 @@ function assertServerSource(src) {
/console\.(log|error)\(/,
'the server must not write log output with bare console.log/console.error (they would bypass the redaction)',
);
// The startup validation runs before the logger is created, so a missing
// required setting still fails fast (E00-S04-T02) before any log output.
const validationIndex = src.indexOf('assertValidConfig({');
assert.doesNotMatch(
src,
/process\.env\.[A-Z_]+/,
'the server must not read process.env directly (all settings flow through the config adapter, E00-S04-T04)',
);
// The startup configuration loads through the adapter (which validates it)
// before the logger is created, so a missing required setting still fails
// fast (E00-S04-T02) before any log output.
const validationIndex = src.indexOf('loadConfigFromEnv(');
const loggerIndex = src.indexOf('createLogger(config)');
assert.ok(
validationIndex !== -1 && loggerIndex !== -1 && validationIndex < loggerIndex,
'the startup validation must run before the logger is created (a missing required setting is still a startup error)',
'the startup configuration must load (and validate) before the logger is created (a missing required setting is still a startup error)',
);
}