Skip to content

Commit b5fc0d5

Browse files
authored
ci: enable more tests on Postgres adapter (#7641)
1 parent 80bf578 commit b5fc0d5

6 files changed

+113
-111
lines changed

spec/ParseAPI.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const headers = {
2323
'X-Parse-Installation-Id': 'yolo',
2424
};
2525

26-
describe_only_db('mongo')('miscellaneous', () => {
26+
describe('miscellaneous', () => {
2727
it('db contains document after successful save', async () => {
2828
const obj = new Parse.Object('TestObject');
2929
obj.set('foo', 'bar');

spec/ParseGraphQLServer.spec.js

+92-95
Original file line numberDiff line numberDiff line change
@@ -4013,64 +4013,61 @@ describe('ParseGraphQLServer', () => {
40134013
expect(someClassSubObject.someClassField).toEqual('imSomeClassTwo');
40144014
});
40154015

4016-
it_only_db('mongo')(
4017-
'should return many child objects in allow cyclic query',
4018-
async () => {
4019-
const obj1 = new Parse.Object('Employee');
4020-
const obj2 = new Parse.Object('Team');
4021-
const obj3 = new Parse.Object('Company');
4022-
const obj4 = new Parse.Object('Country');
4016+
it('should return many child objects in allow cyclic query', async () => {
4017+
const obj1 = new Parse.Object('Employee');
4018+
const obj2 = new Parse.Object('Team');
4019+
const obj3 = new Parse.Object('Company');
4020+
const obj4 = new Parse.Object('Country');
40234021

4024-
obj1.set('name', 'imAnEmployee');
4025-
await obj1.save();
4022+
obj1.set('name', 'imAnEmployee');
4023+
await obj1.save();
40264024

4027-
obj2.set('name', 'imATeam');
4028-
obj2.set('employees', [obj1]);
4029-
await obj2.save();
4025+
obj2.set('name', 'imATeam');
4026+
obj2.set('employees', [obj1]);
4027+
await obj2.save();
40304028

4031-
obj3.set('name', 'imACompany');
4032-
obj3.set('teams', [obj2]);
4033-
obj3.set('employees', [obj1]);
4034-
await obj3.save();
4029+
obj3.set('name', 'imACompany');
4030+
obj3.set('teams', [obj2]);
4031+
obj3.set('employees', [obj1]);
4032+
await obj3.save();
40354033

4036-
obj4.set('name', 'imACountry');
4037-
obj4.set('companies', [obj3]);
4038-
await obj4.save();
4034+
obj4.set('name', 'imACountry');
4035+
obj4.set('companies', [obj3]);
4036+
await obj4.save();
40394037

4040-
obj1.set('country', obj4);
4041-
await obj1.save();
4038+
obj1.set('country', obj4);
4039+
await obj1.save();
40424040

4043-
await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();
4041+
await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();
40444042

4045-
const result = (
4046-
await apolloClient.query({
4047-
query: gql`
4048-
query DeepComplexGraphQLQuery($id: ID!) {
4049-
country(id: $id) {
4050-
objectId
4051-
name
4052-
companies {
4053-
... on Company {
4054-
objectId
4055-
name
4056-
employees {
4057-
... on Employee {
4058-
objectId
4059-
name
4060-
}
4043+
const result = (
4044+
await apolloClient.query({
4045+
query: gql`
4046+
query DeepComplexGraphQLQuery($id: ID!) {
4047+
country(id: $id) {
4048+
objectId
4049+
name
4050+
companies {
4051+
... on Company {
4052+
objectId
4053+
name
4054+
employees {
4055+
... on Employee {
4056+
objectId
4057+
name
40614058
}
4062-
teams {
4063-
... on Team {
4064-
objectId
4065-
name
4066-
employees {
4067-
... on Employee {
4059+
}
4060+
teams {
4061+
... on Team {
4062+
objectId
4063+
name
4064+
employees {
4065+
... on Employee {
4066+
objectId
4067+
name
4068+
country {
40684069
objectId
40694070
name
4070-
country {
4071-
objectId
4072-
name
4073-
}
40744071
}
40754072
}
40764073
}
@@ -4079,54 +4076,54 @@ describe('ParseGraphQLServer', () => {
40794076
}
40804077
}
40814078
}
4082-
`,
4083-
variables: {
4084-
id: obj4.id,
4085-
},
4086-
})
4087-
).data.country;
4079+
}
4080+
`,
4081+
variables: {
4082+
id: obj4.id,
4083+
},
4084+
})
4085+
).data.country;
40884086

4089-
const expectedResult = {
4090-
objectId: obj4.id,
4091-
name: 'imACountry',
4092-
__typename: 'Country',
4093-
companies: [
4094-
{
4095-
objectId: obj3.id,
4096-
name: 'imACompany',
4097-
__typename: 'Company',
4098-
employees: [
4099-
{
4100-
objectId: obj1.id,
4101-
name: 'imAnEmployee',
4102-
__typename: 'Employee',
4103-
},
4104-
],
4105-
teams: [
4106-
{
4107-
objectId: obj2.id,
4108-
name: 'imATeam',
4109-
__typename: 'Team',
4110-
employees: [
4111-
{
4112-
objectId: obj1.id,
4113-
name: 'imAnEmployee',
4114-
__typename: 'Employee',
4115-
country: {
4116-
objectId: obj4.id,
4117-
name: 'imACountry',
4118-
__typename: 'Country',
4119-
},
4087+
const expectedResult = {
4088+
objectId: obj4.id,
4089+
name: 'imACountry',
4090+
__typename: 'Country',
4091+
companies: [
4092+
{
4093+
objectId: obj3.id,
4094+
name: 'imACompany',
4095+
__typename: 'Company',
4096+
employees: [
4097+
{
4098+
objectId: obj1.id,
4099+
name: 'imAnEmployee',
4100+
__typename: 'Employee',
4101+
},
4102+
],
4103+
teams: [
4104+
{
4105+
objectId: obj2.id,
4106+
name: 'imATeam',
4107+
__typename: 'Team',
4108+
employees: [
4109+
{
4110+
objectId: obj1.id,
4111+
name: 'imAnEmployee',
4112+
__typename: 'Employee',
4113+
country: {
4114+
objectId: obj4.id,
4115+
name: 'imACountry',
4116+
__typename: 'Country',
41204117
},
4121-
],
4122-
},
4123-
],
4124-
},
4125-
],
4126-
};
4127-
expect(result).toEqual(expectedResult);
4128-
}
4129-
);
4118+
},
4119+
],
4120+
},
4121+
],
4122+
},
4123+
],
4124+
};
4125+
expect(result).toEqual(expectedResult);
4126+
});
41304127

41314128
it('should respect level permissions', async () => {
41324129
await prepareData();
@@ -8689,7 +8686,7 @@ describe('ParseGraphQLServer', () => {
86898686
expect(result2.companies.edges[0].node.objectId).toEqual(company1.id);
86908687
});
86918688

8692-
it_only_db('mongo')('should support relational where query', async () => {
8689+
it('should support relational where query', async () => {
86938690
const president = new Parse.Object('President');
86948691
president.set('name', 'James');
86958692
await president.save();

spec/ParseObject.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('Parse.Object testing', () => {
223223
});
224224
});
225225

226-
it_exclude_dbs(['postgres'])('can set null', function (done) {
226+
it('can set null', function (done) {
227227
const obj = new Parse.Object('TestObject');
228228
obj.set('foo', null);
229229
obj.save().then(
@@ -232,7 +232,7 @@ describe('Parse.Object testing', () => {
232232
equal(obj.get('foo'), null);
233233
});
234234
on_db('postgres', () => {
235-
fail('should not succeed');
235+
equal(obj.get('foo'), null);
236236
});
237237
done();
238238
},

spec/ParsePolygon.spec.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const TestObject = Parse.Object.extend('TestObject');
2-
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter').default;
3-
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
42
const request = require('../lib/request');
3+
const TestUtils = require('../lib/TestUtils');
54
const defaultHeaders = {
65
'X-Parse-Application-Id': 'test',
76
'X-Parse-Rest-API-Key': 'rest',
@@ -210,7 +209,7 @@ describe('Parse.Polygon testing', () => {
210209

211210
describe('with location', () => {
212211
if (process.env.PARSE_SERVER_TEST_DB !== 'postgres') {
213-
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
212+
beforeEach(async () => await TestUtils.destroyAllDataPermanently());
214213
}
215214

216215
it('polygonContain query', done => {
@@ -425,7 +424,15 @@ describe('Parse.Polygon testing', () => {
425424
});
426425

427426
describe_only_db('mongo')('Parse.Polygon testing', () => {
428-
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
427+
const Config = require('../lib/Config');
428+
let config;
429+
beforeEach(async () => {
430+
if (process.env.PARSE_SERVER_TEST_DB !== 'postgres') {
431+
await TestUtils.destroyAllDataPermanently();
432+
}
433+
config = Config.get('test');
434+
config.schemaCache.clear();
435+
});
429436
it('support 2d and 2dsphere', done => {
430437
const coords = [
431438
[0, 0],
@@ -437,7 +444,7 @@ describe_only_db('mongo')('Parse.Polygon testing', () => {
437444
// testings against REST API, use raw formats
438445
const polygon = { __type: 'Polygon', coordinates: coords };
439446
const location = { __type: 'GeoPoint', latitude: 10, longitude: 10 };
440-
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
447+
const databaseAdapter = config.database.adapter;
441448
return reconfigureServer({
442449
appId: 'test',
443450
restAPIKey: 'rest',

spec/ParseRelation.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe('Parse.Relation testing', () => {
172172
.then(done, done.fail);
173173
});
174174

175-
it_exclude_dbs(['postgres'])('queries with relations', async () => {
175+
it('queries with relations', async () => {
176176
const ChildObject = Parse.Object.extend('ChildObject');
177177
const childObjects = [];
178178
for (let i = 0; i < 10; i++) {
@@ -283,7 +283,7 @@ describe('Parse.Relation testing', () => {
283283
});
284284
});
285285

286-
it_exclude_dbs(['postgres'])('query on pointer and relation fields with equal', done => {
286+
it('query on pointer and relation fields with equal', done => {
287287
const ChildObject = Parse.Object.extend('ChildObject');
288288
const childObjects = [];
289289
for (let i = 0; i < 10; i++) {
@@ -366,7 +366,7 @@ describe('Parse.Relation testing', () => {
366366
});
367367
});
368368

369-
it_exclude_dbs(['postgres'])('or queries on pointer and relation fields', done => {
369+
it('or queries on pointer and relation fields', done => {
370370
const ChildObject = Parse.Object.extend('ChildObject');
371371
const childObjects = [];
372372
for (let i = 0; i < 10; i++) {

spec/SchemaPerformance.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
const Config = require('../lib/Config');
2-
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter').default;
3-
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
42

5-
describe_only_db('mongo')('Schema Performance', function () {
3+
describe('Schema Performance', function () {
64
let getAllSpy;
75
let config;
86

97
beforeEach(async () => {
108
config = Config.get('test');
119
config.schemaCache.clear();
12-
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
10+
const databaseAdapter = config.database.adapter;
1311
await reconfigureServer({ databaseAdapter });
1412
getAllSpy = spyOn(databaseAdapter, 'getAllClasses').and.callThrough();
1513
});
@@ -204,6 +202,6 @@ describe_only_db('mongo')('Schema Performance', function () {
204202
{},
205203
config.database
206204
);
207-
expect(getAllSpy.calls.count()).toBe(0);
205+
expect(getAllSpy.calls.count()).toBe(2);
208206
});
209207
});

0 commit comments

Comments
 (0)