Merge branch 'dev' into fix/red-bun-test
This commit is contained in:
commit
e89aa6cf2c
14 changed files with 1678 additions and 46 deletions
|
|
@ -120,6 +120,49 @@ describe('ServiceContainerBuilder production configuration', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('extracts database from multi-host readUri when mongoReadOnly is enabled', async () => {
|
||||
const config = {
|
||||
...configuration(),
|
||||
database: {
|
||||
...configuration().database,
|
||||
mongodb: {
|
||||
enabled: true,
|
||||
uri: 'mongodb://dev_admin:dev_mongo_pass@localhost:27018/stock_dev?authSource=admin',
|
||||
readUri:
|
||||
'mongodb://studio_stock_bot_read:secret@localhost:27017,localhost:27018/stock?authSource=stock',
|
||||
database: 'stock_dev',
|
||||
},
|
||||
},
|
||||
};
|
||||
const container = await new ServiceContainerBuilder()
|
||||
.withConfig(config)
|
||||
.withOptions({
|
||||
enableMongoDB: true,
|
||||
mongoReadOnly: true,
|
||||
enablePostgres: false,
|
||||
enableQuestDB: false,
|
||||
enableCache: false,
|
||||
enableQueue: false,
|
||||
enableBrowser: false,
|
||||
enableProxy: false,
|
||||
})
|
||||
.skipInitialization()
|
||||
.build();
|
||||
|
||||
try {
|
||||
const resolvedConfig = container.resolve('config');
|
||||
expect(resolvedConfig.mongodb.readOnly).toBe(true);
|
||||
expect(resolvedConfig.mongodb.database).toBe('stock');
|
||||
|
||||
const mongo = container.resolve('mongoClient');
|
||||
expect(mongo).not.toBeNull();
|
||||
expect(mongo!.isReadOnly()).toBe(true);
|
||||
expect(mongo!.getDefaultDatabase()).toBe('stock');
|
||||
} finally {
|
||||
await container.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects invalid settings and missing required app fields with schema errors', () => {
|
||||
expect(() =>
|
||||
new ServiceContainerBuilder().withConfig({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue