Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ beforeEach(function(done) {

afterEach(function(done) {
Parse.User.logOut().then(() => {
return clearData();
return DatabaseAdapter.clearData();
}).then(() => {
done();
}, (error) => {
Expand Down Expand Up @@ -232,14 +232,6 @@ function mockFacebook() {
return facebook;
}

function clearData() {
var promises = [];
for (var conn in DatabaseAdapter.dbConnections) {
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
}
return Promise.all(promises);
}

// This is polluting, but, it makes it way easier to directly port old tests.
global.Parse = Parse;
global.TestObject = TestObject;
Expand Down
10 changes: 10 additions & 0 deletions src/DatabaseAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ function clearDatabaseSettings() {
appDatabaseOptions = {};
}

//Used by tests
function clearData() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could wrap here in:

var clearData = function() {
 throw '';
}
if (process.env.TESTING) {
 clearData = function() {}
}

var promises = [];
for (var conn in dbConnections) {
promises.push(dbConnections[conn].deleteEverything());
}
return Promise.all(promises);
}

function getDatabaseConnection(appId: string, collectionPrefix: string) {
if (dbConnections[appId]) {
return dbConnections[appId];
Expand All @@ -71,5 +80,6 @@ module.exports = {
setAppDatabaseOptions: setAppDatabaseOptions,
setAppDatabaseURI: setAppDatabaseURI,
clearDatabaseSettings: clearDatabaseSettings,
clearData: clearData,
defaultDatabaseURI: databaseURI
};
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ParseServer from './ParseServer';
import GCSAdapter from 'parse-server-gcs-adapter';
import S3Adapter from 'parse-server-s3-adapter';
import FileSystemAdapter from 'parse-server-fs-adapter';
import DatabaseAdapter from './DatabaseAdapter';

if (process.env.VERBOSE || process.env.VERBOSE_PARSE_SERVER) {
winston.level = 'silly';
Expand All @@ -21,4 +22,4 @@ let _ParseServer = function(options) {
_ParseServer.createLiveQueryServer = ParseServer.createLiveQueryServer;

export default ParseServer;
export { S3Adapter, GCSAdapter, FileSystemAdapter, _ParseServer as ParseServer };
export { S3Adapter, GCSAdapter, FileSystemAdapter, DatabaseAdapter, _ParseServer as ParseServer };