Merge pull request #1111 from ParsePlatform/flovilmart.reduceConnectionCount

Reduces the number of connections to mongo created
This commit is contained in:
Fosco Marotto
2016-03-20 11:56:25 -08:00

View File

@@ -51,8 +51,15 @@ var server = app.listen(port);
// Prevent reinitializing the server from clobbering Cloud Code // Prevent reinitializing the server from clobbering Cloud Code
delete defaultConfiguration.cloud; delete defaultConfiguration.cloud;
var currentConfiguration;
// Allows testing specific configurations of Parse Server // Allows testing specific configurations of Parse Server
var setServerConfiguration = configuration => { var setServerConfiguration = configuration => {
// the configuration hasn't changed
if (configuration === currentConfiguration) {
return;
}
DatabaseAdapter.clearDatabaseSettings();
currentConfiguration = configuration;
server.close(); server.close();
cache.clearCache(); cache.clearCache();
app = express(); app = express();
@@ -72,17 +79,17 @@ Parse.serverURL = 'http://localhost:' + port + '/1';
Parse.Promise.disableAPlusCompliant(); Parse.Promise.disableAPlusCompliant();
beforeEach(function(done) { beforeEach(function(done) {
restoreServerConfiguration();
Parse.initialize('test', 'test', 'test'); Parse.initialize('test', 'test', 'test');
Parse.serverURL = 'http://localhost:' + port + '/1';
Parse.User.enableUnsafeCurrentUser(); Parse.User.enableUnsafeCurrentUser();
done(); done();
}); });
afterEach(function(done) { afterEach(function(done) {
restoreServerConfiguration();
Parse.User.logOut().then(() => { Parse.User.logOut().then(() => {
return clearData(); return clearData();
}).then(() => { }).then(() => {
DatabaseAdapter.clearDatabaseSettings();
done(); done();
}, (error) => { }, (error) => {
console.log('error in clearData', error); console.log('error in clearData', error);