Handle shutdown on grid adapters (#5943)

* Handle shutdown on grid adapters

* Add tests

* Fix postgres test
This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2019-08-19 00:35:06 -07:00
committed by Diamond Lewis
parent f5ac94ddb2
commit c951e08f63
6 changed files with 81 additions and 21 deletions

View File

@@ -96,4 +96,19 @@ describe_only_db('mongo')('GridStoreAdapter', () => {
})
.catch(fail);
});
it('handleShutdown, close connection', done => {
const databaseURI = 'mongodb://localhost:27017/parse';
const gridStoreAdapter = new GridStoreAdapter(databaseURI);
gridStoreAdapter._connect().then(db => {
expect(db.serverConfig.connections().length > 0).toEqual(true);
expect(db.serverConfig.s.connected).toEqual(true);
gridStoreAdapter.handleShutdown().then(() => {
expect(db.serverConfig.connections().length > 0).toEqual(false);
expect(db.serverConfig.s.connected).toEqual(false);
done();
});
});
});
});