Patch handleShutdown feature (#4361)
* Add handleShutdown Test of MongoStorageAdapter. * Add `handleShutdown` function in PostgresStorageAdapter, with it's test. * Replace the _pgp to _client * Use `adapter._client.$pool.ending` to ckeck is ending * Add `handleShutdown()` in ParseServer.spec.js * Trigger * Set Server to Default
This commit is contained in:
committed by
Florent Vilmart
parent
de73f3723c
commit
8bf6abfee3
@@ -33,4 +33,35 @@ describe('Server Url Checks', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('handleShutdown, close connection', (done) => {
|
||||
var MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter');
|
||||
const PostgresStorageAdapter = require('../src/Adapters/Storage/Postgres/PostgresStorageAdapter');
|
||||
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
|
||||
const postgresURI = 'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
|
||||
let databaseAdapter;
|
||||
if (process.env.PARSE_SERVER_TEST_DB === 'postgres') {
|
||||
databaseAdapter = new PostgresStorageAdapter({
|
||||
uri: process.env.PARSE_SERVER_TEST_DATABASE_URI || postgresURI,
|
||||
collectionPrefix: 'test_',
|
||||
});
|
||||
} else {
|
||||
databaseAdapter = new MongoStorageAdapter({
|
||||
uri: mongoURI,
|
||||
collectionPrefix: 'test_',
|
||||
});
|
||||
}
|
||||
const newConfiguration = Object.assign({}, defaultConfiguration, { databaseAdapter });
|
||||
const parseServer = ParseServer.start(newConfiguration, () => {
|
||||
parseServer.handleShutdown();
|
||||
parseServer.server.close((err) => {
|
||||
if (err) {
|
||||
done.fail('Close Server Error')
|
||||
}
|
||||
reconfigureServer({}).then(() => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user