ci: Add test support for external database adapter (#8883)
This commit is contained in:
@@ -142,6 +142,25 @@ describe('AdapterLoader', () => {
|
|||||||
}).not.toThrow();
|
}).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 => {
|
it('should load file adapter from direct passing', done => {
|
||||||
spyOn(console, 'warn').and.callFake(() => {});
|
spyOn(console, 'warn').and.callFake(() => {});
|
||||||
const mockFilesAdapter = new MockFilesAdapter('key', 'secret', 'bucket');
|
const mockFilesAdapter = new MockFilesAdapter('key', 'secret', 'bucket');
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ process.noDeprecation = true;
|
|||||||
const cache = require('../lib/cache').default;
|
const cache = require('../lib/cache').default;
|
||||||
const defaults = require('../lib/defaults').default;
|
const defaults = require('../lib/defaults').default;
|
||||||
const ParseServer = require('../lib/index').ParseServer;
|
const ParseServer = require('../lib/index').ParseServer;
|
||||||
|
const loadAdapter = require('../lib/Adapters/AdapterLoader').loadAdapter;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const TestUtils = require('../lib/TestUtils');
|
const TestUtils = require('../lib/TestUtils');
|
||||||
const GridFSBucketAdapter = require('../lib/Adapters/Files/GridFSBucketAdapter')
|
const GridFSBucketAdapter = require('../lib/Adapters/Files/GridFSBucketAdapter')
|
||||||
@@ -53,7 +54,10 @@ let databaseAdapter;
|
|||||||
let databaseURI;
|
let databaseURI;
|
||||||
// need to bind for mocking mocha
|
// 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;
|
databaseURI = process.env.PARSE_SERVER_TEST_DATABASE_URI || postgresURI;
|
||||||
databaseAdapter = new PostgresStorageAdapter({
|
databaseAdapter = new PostgresStorageAdapter({
|
||||||
uri: databaseURI,
|
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
|
// Keys that may include sensitive information that will be redacted in logs
|
||||||
const keysToRedact = [
|
const keysToRedact = [
|
||||||
|
'databaseAdapter',
|
||||||
'databaseURI',
|
'databaseURI',
|
||||||
'masterKey',
|
'masterKey',
|
||||||
'maintenanceKey',
|
'maintenanceKey',
|
||||||
|
|||||||
Reference in New Issue
Block a user