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

@@ -60,4 +60,19 @@ describe('GridFSBucket and GridStore interop', () => {
await gfsAdapter.deleteFile('myFileName');
await expectMissingFile(gfsAdapter, 'myFileName');
});
it('handleShutdown, close connection', done => {
const databaseURI = 'mongodb://localhost:27017/parse';
const gfsAdapter = new GridFSBucketAdapter(databaseURI);
gfsAdapter._connect().then(db => {
expect(db.serverConfig.connections().length > 0).toEqual(true);
expect(db.serverConfig.s.connected).toEqual(true);
gfsAdapter.handleShutdown().then(() => {
expect(db.serverConfig.connections().length > 0).toEqual(false);
expect(db.serverConfig.s.connected).toEqual(false);
done();
});
});
});
});