Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-12-02 21:06:48 +01:00
parent 6cecfbba73
commit 8c84e4ef1f
2 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ export interface Config {
*
* This is merged recursively into the base knexConfig
*/
knexConfig: object;
knexConfig?: object;
};
};
};
@@ -505,5 +505,42 @@ describe('DatabaseManager', () => {
'database_name_overriden',
);
});
it('fetches and merges additional knex config', async () => {
const testManager = DatabaseManager.fromConfig(
new ConfigReader({
backend: {
database: {
client: 'pg',
connection: {
host: 'localhost',
database: 'foodb',
},
knexConfig: {
something: false,
},
plugin: {
testdbname: {
knexConfig: {
debug: true,
},
},
},
},
},
}),
);
await testManager.forPlugin('testdbname').getClient();
const mockCalls = mocked(createDatabaseClient).mock.calls.splice(-1);
const [baseConfig] = mockCalls[0];
expect(baseConfig.data).toEqual(
expect.objectContaining({
debug: true,
something: false,
}),
);
});
});
});