fix: address cleanup review lifecycle and connection settings

This commit is contained in:
Boki 2026-10-26 16:53:53 -04:00
parent 512f2f1c32
commit 9d3e1a7bb9
11 changed files with 264 additions and 17 deletions

View file

@ -88,6 +88,14 @@ test('PostgreSQL nondefault fields reach wire configuration and Mongo retains UR
connectionTimeoutMillis: 4321,
idleTimeoutMillis: 8765,
});
for (const key of [
'query_timeout',
'statement_timeout',
'lock_timeout',
'idle_in_transaction_session_timeout',
] as const) {
expect(wire[key]).toBeUndefined();
}
const mongo = c.resolve('mongoClient') as unknown as {
config: { uri: string; poolSettings: { maxPoolSize: number } };
};
@ -148,3 +156,53 @@ test('all-disabled default composition needs neither store settings nor connecti
await c.dispose();
}
});
test('Redis ACL username reaches cache and both queue connection settings without opening sockets', async () => {
// Isolate the transport substitution: Bun module mocks otherwise leak between suites.
const child = Bun.spawn(
[
process.execPath,
'-e',
String.raw`
import {mock} from 'bun:test';
const captured=[];
class Redis {
constructor(options){captured.push(options);}
on(){return this;}
disconnect(){}
async quit(){}
}
mock.module('ioredis',()=>({default:Redis,Redis,Cluster:Redis}));
const {ServiceContainerBuilder}=await import('./libs/core/di/src/container/builder.ts');
const c=await new ServiceContainerBuilder().withConfig({
name:'redis-auth-test',version:'1.0.0',service:{name:'redis-auth-test',port:3000},log:{level:'fatal'},
database:{dragonfly:{enabled:true,host:'redis.fixture.test',username:'research-reader',password:'fixture-only'},
mongodb:{enabled:false,uri:'mongodb://localhost/test',database:'test'},
postgres:{enabled:false,database:'test',user:'test',password:'fixture-only'},questdb:{enabled:false}},
}).withOptions({enableBrowser:false,enableProxy:false}).skipInitialization().build();
c.resolve('cache');c.resolve('globalCache');
const queue=c.resolve('queueManager');
process.stdout.write('__redis_capture__'+JSON.stringify({captured,queue:queue.redisConnection})+'\n');
await c.dispose();
`,
],
{ stdout: 'pipe', stderr: 'pipe' }
);
const [stdout, stderr, code] = await Promise.all([
new Response(child.stdout).text(),
new Response(child.stderr).text(),
child.exited,
]);
if (code !== 0) throw new Error(`Redis transport probe failed: ${stderr}`);
const line = stdout.split('\n').find(line => line.startsWith('__redis_capture__'));
expect(line).toBeDefined();
const result = JSON.parse(line!.slice('__redis_capture__'.length));
expect(result.captured).toHaveLength(2);
for (const config of [...result.captured, result.queue]) {
expect(config).toMatchObject({
host: 'redis.fixture.test',
username: 'research-reader',
password: 'fixture-only',
});
}
});