Store collection prefix in mongo adapter, and clean up adapter interface (#1472)
This commit is contained in:
@@ -8,15 +8,15 @@ describe('DatabaseAdapter', () => {
|
||||
DatabaseAdapter.setAppDatabaseOptions('optionsTest', {foo: "bar"});
|
||||
let optionsTestDatabaseConnection = DatabaseAdapter.getDatabaseConnection('optionsTest');
|
||||
|
||||
expect(optionsTestDatabaseConnection instanceof Object).toBe(true);
|
||||
expect(optionsTestDatabaseConnection.adapter._options instanceof Object).toBe(true);
|
||||
expect(optionsTestDatabaseConnection.adapter._options.foo).toBe("bar");
|
||||
expect(optionsTestDatabaseConnection).toEqual(jasmine.any(Object));
|
||||
expect(optionsTestDatabaseConnection.adapter._mongoOptions).toEqual(jasmine.any(Object));
|
||||
expect(optionsTestDatabaseConnection.adapter._mongoOptions.foo).toBe("bar");
|
||||
|
||||
DatabaseAdapter.setAppDatabaseURI('noOptionsTest', 'mongodb://localhost:27017/noOptionsTest');
|
||||
let noOptionsTestDatabaseConnection = DatabaseAdapter.getDatabaseConnection('noOptionsTest');
|
||||
|
||||
expect(noOptionsTestDatabaseConnection instanceof Object).toBe(true);
|
||||
expect(noOptionsTestDatabaseConnection.adapter._options instanceof Object).toBe(false);
|
||||
expect(noOptionsTestDatabaseConnection).toEqual(jasmine.any(Object));
|
||||
expect(noOptionsTestDatabaseConnection.adapter._mongoOptions).toEqual(jasmine.any(Object));
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -5,9 +5,11 @@ let MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAda
|
||||
|
||||
describe('DatabaseController', () => {
|
||||
it('can be constructed', done => {
|
||||
let adapter = new MongoStorageAdapter('mongodb://localhost:27017/test');
|
||||
let adapter = new MongoStorageAdapter({
|
||||
uri: 'mongodb://localhost:27017/test'
|
||||
});
|
||||
let databaseController = new DatabaseController(adapter, {
|
||||
collectionPrefix: 'test_'
|
||||
collectionPrefix: 'test_'
|
||||
});
|
||||
databaseController.connect().then(done, error => {
|
||||
console.log('error', error.stack);
|
||||
|
||||
@@ -6,8 +6,9 @@ const MongoClient = require('mongodb').MongoClient;
|
||||
describe('MongoStorageAdapter', () => {
|
||||
it('auto-escapes symbols in auth information', () => {
|
||||
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
||||
new MongoStorageAdapter('mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse', {})
|
||||
.connect();
|
||||
new MongoStorageAdapter({
|
||||
uri: 'mongodb://user!with@+ symbols:password!with@+ symbols@localhost:1234/parse'
|
||||
}).connect();
|
||||
expect(MongoClient.connect).toHaveBeenCalledWith(
|
||||
'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
|
||||
jasmine.any(Object)
|
||||
@@ -16,8 +17,9 @@ describe('MongoStorageAdapter', () => {
|
||||
|
||||
it("doesn't double escape already URI-encoded information", () => {
|
||||
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
||||
new MongoStorageAdapter('mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse', {})
|
||||
.connect();
|
||||
new MongoStorageAdapter({
|
||||
uri: 'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse'
|
||||
}).connect();
|
||||
expect(MongoClient.connect).toHaveBeenCalledWith(
|
||||
'mongodb://user!with%40%2B%20symbols:password!with%40%2B%20symbols@localhost:1234/parse',
|
||||
jasmine.any(Object)
|
||||
@@ -27,8 +29,9 @@ describe('MongoStorageAdapter', () => {
|
||||
// https://github.com/ParsePlatform/parse-server/pull/148#issuecomment-180407057
|
||||
it('preserves replica sets', () => {
|
||||
spyOn(MongoClient, 'connect').and.returnValue(Promise.resolve(null));
|
||||
new MongoStorageAdapter('mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415', {})
|
||||
.connect();
|
||||
new MongoStorageAdapter({
|
||||
uri: 'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415'
|
||||
}).connect();
|
||||
expect(MongoClient.connect).toHaveBeenCalledWith(
|
||||
'mongodb://test:testpass@ds056315-a0.mongolab.com:59325,ds059315-a1.mongolab.com:59315/testDBname?replicaSet=rs-ds059415',
|
||||
jasmine.any(Object)
|
||||
|
||||
Reference in New Issue
Block a user