Skip to content

Commit 9ab488b

Browse files
authored
Postgres: $all, $and CLP and more (#2551)
* Adds passing tests * Better containsAll implementation * Full Geopoint support, fix inverted lat/lng * Adds support for $and operator / PointerPermissions specs * Fix issue updating CLPs on schema * Extends query support * Adds RestCreate to the specs * Adds User specs * Adds error handlers for failing tests * nits * Proper JSON update of AuthData * fix for #1259 with PG * Fix for Installations _PushStatus test * Adds support for GlobalConfig * Enables relations tests * Exclude spec as legacy * Makes corner case for 1 in GlobalConfig
1 parent e1de9f3 commit 9ab488b

17 files changed

+276
-138
lines changed

spec/InstallationsRouter.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ describe('InstallationsRouter', () => {
7575
expect(results.length).toEqual(1);
7676
done();
7777
}).catch((err) => {
78-
console.error(err);
79-
fail(JSON.stringify(err));
78+
jfail(err);
8079
done();
8180
});
8281
});

spec/ParseAPI.spec.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('miscellaneous', function() {
113113
.catch(done);
114114
});
115115

116-
it_exclude_dbs(['postgres'])('ensure that email is uniquely indexed', done => {
116+
it('ensure that email is uniquely indexed', done => {
117117
let numFailed = 0;
118118
let numCreated = 0;
119119
let user1 = new Parse.User();
@@ -212,7 +212,7 @@ describe('miscellaneous', function() {
212212
});
213213
});
214214

215-
it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
215+
it('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
216216
let config = new Config('test');
217217
config.database.adapter.addFieldIfNotExists('_User', 'randomField', { type: 'String' })
218218
.then(() => config.database.adapter.ensureUniqueness('_User', userSchema, ['randomField']))
@@ -233,7 +233,6 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
233233
return user.signUp()
234234
})
235235
.catch(error => {
236-
console.error(error);
237236
expect(error.code).toEqual(Parse.Error.DUPLICATE_VALUE);
238237
done();
239238
});
@@ -1363,7 +1362,7 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
13631362
});
13641363
});
13651364

1366-
it_exclude_dbs(['postgres'])('does not change inner objects if the key has the same name as a geopoint field on the class, and the value is an array of length 2, or if the key has the same name as a file field on the class, and the value is a string', done => {
1365+
it('does not change inner objects if the key has the same name as a geopoint field on the class, and the value is an array of length 2, or if the key has the same name as a file field on the class, and the value is a string', done => {
13671366
let file = new Parse.File('myfile.txt', { base64: 'eAo=' });
13681367
file.save()
13691368
.then(f => {
@@ -1495,8 +1494,10 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
14951494
done();
14961495
});
14971496
});
1497+
});
14981498

1499-
it_exclude_dbs(['postgres'])('should have _acl when locking down (regression for #2465)', (done) =>  {
1499+
describe_only_db('mongo')('legacy _acl', () => {
1500+
it('should have _acl when locking down (regression for #2465)', (done) =>  {
15001501
let headers = {
15011502
'X-Parse-Application-Id': 'test',
15021503
'X-Parse-REST-API-Key': 'rest'

spec/ParseGeoPoint.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe('Parse.GeoPoint testing', () => {
273273
});
274274
});
275275

276-
it_exclude_dbs(['postgres'])('works with geobox queries', (done) => {
276+
it('works with geobox queries', (done) => {
277277
var inSF = new Parse.GeoPoint(37.75, -122.4);
278278
var southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398);
279279
var northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962);

spec/ParseGlobalConfig.spec.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ let Config = require('../src/Config');
77
describe('a GlobalConfig', () => {
88
beforeEach(done => {
99
let config = new Config('test');
10+
let query = on_db('mongo', () => {
11+
// Legacy is with an int...
12+
return { objectId: 1 };
13+
}, () => {
14+
return { objectId: "1" }
15+
})
1016
config.database.adapter.upsertOneObject(
1117
'_GlobalConfig',
12-
{ fields: {} },
13-
{ objectId: 1 },
18+
{ fields: { objectId: { type: 'Number' }, params: {type: 'Object'}} },
19+
query,
1420
{ params: { companies: ['US', 'DK'] } }
15-
).then(done, done);
21+
).then(done, (err) => {
22+
jfail(err);
23+
done();
24+
});
1625
});
1726

18-
it_exclude_dbs(['postgres'])('can be retrieved', (done) => {
27+
it('can be retrieved', (done) => {
1928
request.get({
2029
url : 'http://localhost:8378/1/config',
2130
json : true,
@@ -32,7 +41,7 @@ describe('a GlobalConfig', () => {
3241
});
3342
});
3443

35-
it_exclude_dbs(['postgres'])('can be updated when a master key exists', (done) => {
44+
it('can be updated when a master key exists', (done) => {
3645
request.put({
3746
url : 'http://localhost:8378/1/config',
3847
json : true,
@@ -48,7 +57,7 @@ describe('a GlobalConfig', () => {
4857
});
4958
});
5059

51-
it_exclude_dbs(['postgres'])('properly handles delete op', (done) => {
60+
it('properly handles delete op', (done) => {
5261
request.put({
5362
url : 'http://localhost:8378/1/config',
5463
json : true,
@@ -79,7 +88,7 @@ describe('a GlobalConfig', () => {
7988
});
8089
});
8190

82-
it_exclude_dbs(['postgres'])('fail to update if master key is missing', (done) => {
91+
it('fail to update if master key is missing', (done) => {
8392
request.put({
8493
url : 'http://localhost:8378/1/config',
8594
json : true,
@@ -95,12 +104,12 @@ describe('a GlobalConfig', () => {
95104
});
96105
});
97106

98-
it_exclude_dbs(['postgres'])('failed getting config when it is missing', (done) => {
107+
it('failed getting config when it is missing', (done) => {
99108
let config = new Config('test');
100109
config.database.adapter.deleteObjectsByQuery(
101110
'_GlobalConfig',
102111
{ fields: { params: { __type: 'String' } } },
103-
{ objectId: 1 }
112+
{ objectId: "1" }
104113
).then(() => {
105114
request.get({
106115
url : 'http://localhost:8378/1/config',

spec/ParseObject.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,7 @@ describe('Parse.Object testing', () => {
665665
expect(x3.get('stuff')).toEqual([1, {'foo': 'bar'}]);
666666
done();
667667
}, (error) => {
668-
console.error(error);
669-
on_db('mongo', () => {
670-
jfail(error);
671-
});
672-
on_db('postgres', () => {
673-
expect(error.message).toEqual("Postgres does not support Remove operator.");
674-
});
668+
jfail(error);
675669
done();
676670
});
677671
});

spec/ParseQuery.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe('Parse.Query testing', () => {
233233
});
234234
});
235235

236-
it_exclude_dbs(['postgres'])("containsAll date array queries", function(done) {
236+
it("containsAll date array queries", function(done) {
237237
var DateSet = Parse.Object.extend({ className: "DateSet" });
238238

239239
function parseDate(iso8601) {
@@ -289,7 +289,7 @@ describe('Parse.Query testing', () => {
289289
});
290290
});
291291

292-
it_exclude_dbs(['postgres'])("containsAll object array queries", function(done) {
292+
it("containsAll object array queries", function(done) {
293293

294294
var MessageSet = Parse.Object.extend({ className: "MessageSet" });
295295

@@ -872,7 +872,7 @@ describe('Parse.Query testing', () => {
872872
});
873873
});
874874

875-
it_exclude_dbs(['postgres'])("order by descending number and string", function(done) {
875+
it("order by descending number and string", function(done) {
876876
var strings = ["a", "b", "c", "d"];
877877
var makeBoxedNumber = function(num, i) {
878878
return new BoxedNumber({ number: num, string: strings[i] });
@@ -1579,7 +1579,7 @@ describe('Parse.Query testing', () => {
15791579
})
15801580
});
15811581

1582-
it_exclude_dbs(['postgres'])('properly includes array of mixed objects', (done) => {
1582+
it('properly includes array of mixed objects', (done) => {
15831583
let objects = [];
15841584
let total = 0;
15851585
while(objects.length != 5) {
@@ -2270,7 +2270,7 @@ describe('Parse.Query testing', () => {
22702270
});
22712271
});
22722272

2273-
it_exclude_dbs(['postgres'])('notEqual with array of pointers', (done) => {
2273+
it('notEqual with array of pointers', (done) => {
22742274
var children = [];
22752275
var parents = [];
22762276
var promises = [];
@@ -2364,7 +2364,7 @@ describe('Parse.Query testing', () => {
23642364
});
23652365
});
23662366

2367-
it_exclude_dbs(['postgres'])('query match on array with single object', (done) => {
2367+
it('query match on array with single object', (done) => {
23682368
var target = {__type: 'Pointer', className: 'TestObject', objectId: 'abc123'};
23692369
var obj = new Parse.Object('TestObject');
23702370
obj.set('someObjs', [target]);
@@ -2380,7 +2380,7 @@ describe('Parse.Query testing', () => {
23802380
});
23812381
});
23822382

2383-
it_exclude_dbs(['postgres'])('query match on array with multiple objects', (done) => {
2383+
it('query match on array with multiple objects', (done) => {
23842384
var target1 = {__type: 'Pointer', className: 'TestObject', objectId: 'abc'};
23852385
var target2 = {__type: 'Pointer', className: 'TestObject', objectId: '123'};
23862386
var obj= new Parse.Object('TestObject');
@@ -2449,7 +2449,7 @@ describe('Parse.Query testing', () => {
24492449
});
24502450
});
24512451

2452-
it_exclude_dbs(['postgres'])('should find objects with array of pointers', (done) => {
2452+
it('should find objects with array of pointers', (done) => {
24532453
var objects = [];
24542454
while(objects.length != 5) {
24552455
var object = new Parse.Object('ContainedObject');
@@ -2488,7 +2488,7 @@ describe('Parse.Query testing', () => {
24882488
})
24892489
})
24902490

2491-
it_exclude_dbs(['postgres'])('query with two OR subqueries (regression test #1259)', done => {
2491+
it('query with two OR subqueries (regression test #1259)', done => {
24922492
let relatedObject = new Parse.Object('Class2');
24932493
relatedObject.save().then(relatedObject => {
24942494
let anObject = new Parse.Object('Class1');

spec/ParseRelation.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ describe('Parse.Relation testing', () => {
296296
});
297297
});
298298

299-
it_exclude_dbs(['postgres'])("query on pointer and relation fields with equal", (done) => {
299+
it("query on pointer and relation fields with equal", (done) => {
300300
var ChildObject = Parse.Object.extend("ChildObject");
301301
var childObjects = [];
302302
for (var i = 0; i < 10; i++) {
@@ -377,7 +377,7 @@ describe('Parse.Relation testing', () => {
377377
});
378378
});
379379

380-
it_exclude_dbs(['postgres'])("or queries on pointer and relation fields", (done) => {
380+
it("or queries on pointer and relation fields", (done) => {
381381
var ChildObject = Parse.Object.extend("ChildObject");
382382
var childObjects = [];
383383
for (var i = 0; i < 10; i++) {

spec/ParseUser.spec.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ describe('Parse.User testing', () => {
12731273

12741274
// What this means is, only one Parse User can be linked to a
12751275
// particular Facebook account.
1276-
it_exclude_dbs(['postgres'])("link with provider for already linked user", (done) => {
1276+
it("link with provider for already linked user", (done) => {
12771277
var provider = getMockFacebookProvider();
12781278
Parse.User._registerAuthenticationProvider(provider);
12791279
var user = new Parse.User();
@@ -1295,7 +1295,10 @@ describe('Parse.User testing', () => {
12951295
user2.signUp(null, {
12961296
success: function(model) {
12971297
user2._linkWith('facebook', {
1298-
success: fail,
1298+
success: (err) => {
1299+
jfail(err);
1300+
done();
1301+
},
12991302
error: function(model, error) {
13001303
expect(error.code).toEqual(
13011304
Parse.Error.ACCOUNT_ALREADY_LINKED);
@@ -2066,7 +2069,7 @@ describe('Parse.User testing', () => {
20662069
});
20672070
});
20682071

2069-
it_exclude_dbs(['postgres'])('get session only for current user', (done) => {
2072+
it('get session only for current user', (done) => {
20702073
Parse.Promise.as().then(() => {
20712074
return Parse.User.signUp("test1", "test", { foo: "bar" });
20722075
}).then(() => {
@@ -2094,7 +2097,7 @@ describe('Parse.User testing', () => {
20942097
});
20952098
});
20962099

2097-
it_exclude_dbs(['postgres'])('delete session by object', (done) => {
2100+
it('delete session by object', (done) => {
20982101
Parse.Promise.as().then(() => {
20992102
return Parse.User.signUp("test1", "test", { foo: "bar" });
21002103
}).then(() => {

spec/PointerPermissions.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Pointer Permissions', () => {
99
new Config(Parse.applicationId).database.schemaCache.clear();
1010
});
1111

12-
it_exclude_dbs(['postgres'])('should work with find', (done) => {
12+
it('should work with find', (done) => {
1313
let config = new Config(Parse.applicationId);
1414
let user = new Parse.User();
1515
let user2 = new Parse.User();
@@ -48,7 +48,7 @@ describe('Pointer Permissions', () => {
4848
});
4949

5050

51-
it_exclude_dbs(['postgres'])('should work with write', (done) => {
51+
it('should work with write', (done) => {
5252
let config = new Config(Parse.applicationId);
5353
let user = new Parse.User();
5454
let user2 = new Parse.User();
@@ -113,7 +113,7 @@ describe('Pointer Permissions', () => {
113113
})
114114
});
115115

116-
it_exclude_dbs(['postgres'])('should let a proper user find', (done) => {
116+
it('should let a proper user find', (done) => {
117117
let config = new Config(Parse.applicationId);
118118
let user = new Parse.User();
119119
let user2 = new Parse.User();
@@ -199,7 +199,7 @@ describe('Pointer Permissions', () => {
199199
})
200200
});
201201

202-
it_exclude_dbs(['postgres'])('should handle multiple writeUserFields', done => {
202+
it('should handle multiple writeUserFields', done => {
203203
let config = new Config(Parse.applicationId);
204204
let user = new Parse.User();
205205
let user2 = new Parse.User();
@@ -281,7 +281,7 @@ describe('Pointer Permissions', () => {
281281
})
282282
});
283283

284-
it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (PP Locked)', (done) => {
284+
it('tests CLP / Pointer Perms / ACL write (PP Locked)', (done) => {
285285
/*
286286
tests:
287287
CLP: update closed ({})
@@ -328,7 +328,7 @@ describe('Pointer Permissions', () => {
328328
});
329329
});
330330

331-
it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (ACL Locked)', (done) => {
331+
it('tests CLP / Pointer Perms / ACL write (ACL Locked)', (done) => {
332332
/*
333333
tests:
334334
CLP: update closed ({})
@@ -373,7 +373,7 @@ describe('Pointer Permissions', () => {
373373
});
374374
});
375375

376-
it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (ACL/PP OK)', (done) => {
376+
it('tests CLP / Pointer Perms / ACL write (ACL/PP OK)', (done) => {
377377
/*
378378
tests:
379379
CLP: update closed ({})
@@ -418,7 +418,7 @@ describe('Pointer Permissions', () => {
418418
});
419419
});
420420

421-
it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL read (PP locked)', (done) => {
421+
it('tests CLP / Pointer Perms / ACL read (PP locked)', (done) => {
422422
/*
423423
tests:
424424
CLP: find/get open ({})

spec/PushController.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('PushController', () => {
357357
})
358358
});
359359

360-
it_exclude_dbs(['postgres'])('should support full RESTQuery for increment', (done) => {
360+
it('should support full RESTQuery for increment', (done) => {
361361
var payload = {data: {
362362
alert: "Hello World!",
363363
badge: 'Increment',
@@ -392,7 +392,7 @@ describe('PushController', () => {
392392
pushController.sendPush(payload, where, config, auth).then((result) => {
393393
done();
394394
}).catch((err) => {
395-
fail('should not fail');
395+
jfail(err);
396396
done();
397397
});
398398
});

0 commit comments

Comments
 (0)