ci: Add test support for external database adapter (#8883)
This commit is contained in:
@@ -142,6 +142,25 @@ describe('AdapterLoader', () => {
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('should load custom database adapter from config', done => {
|
||||
const adapterPath = require('path').resolve('./spec/support/MockDatabaseAdapter');
|
||||
const options = {
|
||||
databaseURI: 'oracledb://user:password@localhost:1521/freepdb1',
|
||||
collectionPrefix: '',
|
||||
};
|
||||
const databaseAdapterOptions = {
|
||||
adapter: adapterPath,
|
||||
options,
|
||||
};
|
||||
expect(() => {
|
||||
const databaseAdapter = loadAdapter(databaseAdapterOptions);
|
||||
expect(databaseAdapter).not.toBe(undefined);
|
||||
expect(databaseAdapter.options).toEqual(options);
|
||||
expect(databaseAdapter.getDatabaseURI()).toEqual(options.databaseURI);
|
||||
}).not.toThrow();
|
||||
done();
|
||||
});
|
||||
|
||||
it('should load file adapter from direct passing', done => {
|
||||
spyOn(console, 'warn').and.callFake(() => {});
|
||||
const mockFilesAdapter = new MockFilesAdapter('key', 'secret', 'bucket');
|
||||
|
||||
@@ -35,6 +35,7 @@ process.noDeprecation = true;
|
||||
const cache = require('../lib/cache').default;
|
||||
const defaults = require('../lib/defaults').default;
|
||||
const ParseServer = require('../lib/index').ParseServer;
|
||||
const loadAdapter = require('../lib/Adapters/AdapterLoader').loadAdapter;
|
||||
const path = require('path');
|
||||
const TestUtils = require('../lib/TestUtils');
|
||||
const GridFSBucketAdapter = require('../lib/Adapters/Files/GridFSBucketAdapter')
|
||||
@@ -53,7 +54,10 @@ let databaseAdapter;
|
||||
let databaseURI;
|
||||
// need to bind for mocking mocha
|
||||
|
||||
if (process.env.PARSE_SERVER_TEST_DB === 'postgres') {
|
||||
if (process.env.PARSE_SERVER_DATABASE_ADAPTER) {
|
||||
databaseAdapter = JSON.parse(process.env.PARSE_SERVER_DATABASE_ADAPTER);
|
||||
databaseAdapter = loadAdapter(databaseAdapter);
|
||||
} else if (process.env.PARSE_SERVER_TEST_DB === 'postgres') {
|
||||
databaseURI = process.env.PARSE_SERVER_TEST_DATABASE_URI || postgresURI;
|
||||
databaseAdapter = new PostgresStorageAdapter({
|
||||
uri: databaseURI,
|
||||
|
||||
9
spec/support/MockDatabaseAdapter.js
Normal file
9
spec/support/MockDatabaseAdapter.js
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = function (options) {
|
||||
return {
|
||||
options: options,
|
||||
send: function () {},
|
||||
getDatabaseURI: function () {
|
||||
return options.databaseURI;
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -6,6 +6,7 @@ function logStartupOptions(options) {
|
||||
}
|
||||
// Keys that may include sensitive information that will be redacted in logs
|
||||
const keysToRedact = [
|
||||
'databaseAdapter',
|
||||
'databaseURI',
|
||||
'masterKey',
|
||||
'maintenanceKey',
|
||||
|
||||
Reference in New Issue
Block a user