Reduces the number of connections to mongo created

This commit is contained in:
Florent Vilmart
2016-03-20 10:34:55 -04:00
parent c39ba3bdc7
commit 44add9d6ac

View File

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