File tree 4 files changed +34
-1
lines changed
4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,25 @@ describe('AdapterLoader', () => {
142
142
} ) . not . toThrow ( ) ;
143
143
} ) ;
144
144
145
+ it ( 'should load custom database adapter from config' , done => {
146
+ const adapterPath = require ( 'path' ) . resolve ( './spec/support/MockDatabaseAdapter' ) ;
147
+ const options = {
148
+ databaseURI : 'oracledb://user:password@localhost:1521/freepdb1' ,
149
+ collectionPrefix : '' ,
150
+ } ;
151
+ const databaseAdapterOptions = {
152
+ adapter : adapterPath ,
153
+ options,
154
+ } ;
155
+ expect ( ( ) => {
156
+ const databaseAdapter = loadAdapter ( databaseAdapterOptions ) ;
157
+ expect ( databaseAdapter ) . not . toBe ( undefined ) ;
158
+ expect ( databaseAdapter . options ) . toEqual ( options ) ;
159
+ expect ( databaseAdapter . getDatabaseURI ( ) ) . toEqual ( options . databaseURI ) ;
160
+ } ) . not . toThrow ( ) ;
161
+ done ( ) ;
162
+ } ) ;
163
+
145
164
it ( 'should load file adapter from direct passing' , done => {
146
165
spyOn ( console , 'warn' ) . and . callFake ( ( ) => { } ) ;
147
166
const mockFilesAdapter = new MockFilesAdapter ( 'key' , 'secret' , 'bucket' ) ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ process.noDeprecation = true;
35
35
const cache = require ( '../lib/cache' ) . default ;
36
36
const defaults = require ( '../lib/defaults' ) . default ;
37
37
const ParseServer = require ( '../lib/index' ) . ParseServer ;
38
+ const loadAdapter = require ( '../lib/Adapters/AdapterLoader' ) . loadAdapter ;
38
39
const path = require ( 'path' ) ;
39
40
const TestUtils = require ( '../lib/TestUtils' ) ;
40
41
const GridFSBucketAdapter = require ( '../lib/Adapters/Files/GridFSBucketAdapter' )
@@ -53,7 +54,10 @@ let databaseAdapter;
53
54
let databaseURI ;
54
55
// need to bind for mocking mocha
55
56
56
- if ( process . env . PARSE_SERVER_TEST_DB === 'postgres' ) {
57
+ if ( process . env . PARSE_SERVER_DATABASE_ADAPTER ) {
58
+ databaseAdapter = JSON . parse ( process . env . PARSE_SERVER_DATABASE_ADAPTER ) ;
59
+ databaseAdapter = loadAdapter ( databaseAdapter ) ;
60
+ } else if ( process . env . PARSE_SERVER_TEST_DB === 'postgres' ) {
57
61
databaseURI = process . env . PARSE_SERVER_TEST_DATABASE_URI || postgresURI ;
58
62
databaseAdapter = new PostgresStorageAdapter ( {
59
63
uri : databaseURI ,
Original file line number Diff line number Diff line change
1
+ module . exports = function ( options ) {
2
+ return {
3
+ options : options ,
4
+ send : function ( ) { } ,
5
+ getDatabaseURI : function ( ) {
6
+ return options . databaseURI ;
7
+ } ,
8
+ } ;
9
+ } ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ function logStartupOptions(options) {
6
6
}
7
7
// Keys that may include sensitive information that will be redacted in logs
8
8
const keysToRedact = [
9
+ 'databaseAdapter' ,
9
10
'databaseURI' ,
10
11
'masterKey' ,
11
12
'maintenanceKey' ,
You can’t perform that action at this time.
0 commit comments