ci: enable more tests on Postgres adapter (#7641)
This commit is contained in:
@@ -23,7 +23,7 @@ const headers = {
|
|||||||
'X-Parse-Installation-Id': 'yolo',
|
'X-Parse-Installation-Id': 'yolo',
|
||||||
};
|
};
|
||||||
|
|
||||||
describe_only_db('mongo')('miscellaneous', () => {
|
describe('miscellaneous', () => {
|
||||||
it('db contains document after successful save', async () => {
|
it('db contains document after successful save', async () => {
|
||||||
const obj = new Parse.Object('TestObject');
|
const obj = new Parse.Object('TestObject');
|
||||||
obj.set('foo', 'bar');
|
obj.set('foo', 'bar');
|
||||||
|
|||||||
@@ -4013,64 +4013,61 @@ describe('ParseGraphQLServer', () => {
|
|||||||
expect(someClassSubObject.someClassField).toEqual('imSomeClassTwo');
|
expect(someClassSubObject.someClassField).toEqual('imSomeClassTwo');
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_db('mongo')(
|
it('should return many child objects in allow cyclic query', async () => {
|
||||||
'should return many child objects in allow cyclic query',
|
const obj1 = new Parse.Object('Employee');
|
||||||
async () => {
|
const obj2 = new Parse.Object('Team');
|
||||||
const obj1 = new Parse.Object('Employee');
|
const obj3 = new Parse.Object('Company');
|
||||||
const obj2 = new Parse.Object('Team');
|
const obj4 = new Parse.Object('Country');
|
||||||
const obj3 = new Parse.Object('Company');
|
|
||||||
const obj4 = new Parse.Object('Country');
|
|
||||||
|
|
||||||
obj1.set('name', 'imAnEmployee');
|
obj1.set('name', 'imAnEmployee');
|
||||||
await obj1.save();
|
await obj1.save();
|
||||||
|
|
||||||
obj2.set('name', 'imATeam');
|
obj2.set('name', 'imATeam');
|
||||||
obj2.set('employees', [obj1]);
|
obj2.set('employees', [obj1]);
|
||||||
await obj2.save();
|
await obj2.save();
|
||||||
|
|
||||||
obj3.set('name', 'imACompany');
|
obj3.set('name', 'imACompany');
|
||||||
obj3.set('teams', [obj2]);
|
obj3.set('teams', [obj2]);
|
||||||
obj3.set('employees', [obj1]);
|
obj3.set('employees', [obj1]);
|
||||||
await obj3.save();
|
await obj3.save();
|
||||||
|
|
||||||
obj4.set('name', 'imACountry');
|
obj4.set('name', 'imACountry');
|
||||||
obj4.set('companies', [obj3]);
|
obj4.set('companies', [obj3]);
|
||||||
await obj4.save();
|
await obj4.save();
|
||||||
|
|
||||||
obj1.set('country', obj4);
|
obj1.set('country', obj4);
|
||||||
await obj1.save();
|
await obj1.save();
|
||||||
|
|
||||||
await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();
|
await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear();
|
||||||
|
|
||||||
const result = (
|
const result = (
|
||||||
await apolloClient.query({
|
await apolloClient.query({
|
||||||
query: gql`
|
query: gql`
|
||||||
query DeepComplexGraphQLQuery($id: ID!) {
|
query DeepComplexGraphQLQuery($id: ID!) {
|
||||||
country(id: $id) {
|
country(id: $id) {
|
||||||
objectId
|
objectId
|
||||||
name
|
name
|
||||||
companies {
|
companies {
|
||||||
... on Company {
|
... on Company {
|
||||||
objectId
|
objectId
|
||||||
name
|
name
|
||||||
employees {
|
employees {
|
||||||
... on Employee {
|
... on Employee {
|
||||||
objectId
|
objectId
|
||||||
name
|
name
|
||||||
}
|
|
||||||
}
|
}
|
||||||
teams {
|
}
|
||||||
... on Team {
|
teams {
|
||||||
objectId
|
... on Team {
|
||||||
name
|
objectId
|
||||||
employees {
|
name
|
||||||
... on Employee {
|
employees {
|
||||||
|
... on Employee {
|
||||||
|
objectId
|
||||||
|
name
|
||||||
|
country {
|
||||||
objectId
|
objectId
|
||||||
name
|
name
|
||||||
country {
|
|
||||||
objectId
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4079,54 +4076,54 @@ describe('ParseGraphQLServer', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
}
|
||||||
variables: {
|
`,
|
||||||
id: obj4.id,
|
variables: {
|
||||||
},
|
id: obj4.id,
|
||||||
})
|
},
|
||||||
).data.country;
|
})
|
||||||
|
).data.country;
|
||||||
|
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
objectId: obj4.id,
|
objectId: obj4.id,
|
||||||
name: 'imACountry',
|
name: 'imACountry',
|
||||||
__typename: 'Country',
|
__typename: 'Country',
|
||||||
companies: [
|
companies: [
|
||||||
{
|
{
|
||||||
objectId: obj3.id,
|
objectId: obj3.id,
|
||||||
name: 'imACompany',
|
name: 'imACompany',
|
||||||
__typename: 'Company',
|
__typename: 'Company',
|
||||||
employees: [
|
employees: [
|
||||||
{
|
{
|
||||||
objectId: obj1.id,
|
objectId: obj1.id,
|
||||||
name: 'imAnEmployee',
|
name: 'imAnEmployee',
|
||||||
__typename: 'Employee',
|
__typename: 'Employee',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
teams: [
|
teams: [
|
||||||
{
|
{
|
||||||
objectId: obj2.id,
|
objectId: obj2.id,
|
||||||
name: 'imATeam',
|
name: 'imATeam',
|
||||||
__typename: 'Team',
|
__typename: 'Team',
|
||||||
employees: [
|
employees: [
|
||||||
{
|
{
|
||||||
objectId: obj1.id,
|
objectId: obj1.id,
|
||||||
name: 'imAnEmployee',
|
name: 'imAnEmployee',
|
||||||
__typename: 'Employee',
|
__typename: 'Employee',
|
||||||
country: {
|
country: {
|
||||||
objectId: obj4.id,
|
objectId: obj4.id,
|
||||||
name: 'imACountry',
|
name: 'imACountry',
|
||||||
__typename: 'Country',
|
__typename: 'Country',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
};
|
],
|
||||||
expect(result).toEqual(expectedResult);
|
};
|
||||||
}
|
expect(result).toEqual(expectedResult);
|
||||||
);
|
});
|
||||||
|
|
||||||
it('should respect level permissions', async () => {
|
it('should respect level permissions', async () => {
|
||||||
await prepareData();
|
await prepareData();
|
||||||
@@ -8689,7 +8686,7 @@ describe('ParseGraphQLServer', () => {
|
|||||||
expect(result2.companies.edges[0].node.objectId).toEqual(company1.id);
|
expect(result2.companies.edges[0].node.objectId).toEqual(company1.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_db('mongo')('should support relational where query', async () => {
|
it('should support relational where query', async () => {
|
||||||
const president = new Parse.Object('President');
|
const president = new Parse.Object('President');
|
||||||
president.set('name', 'James');
|
president.set('name', 'James');
|
||||||
await president.save();
|
await president.save();
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ describe('Parse.Object testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it_exclude_dbs(['postgres'])('can set null', function (done) {
|
it('can set null', function (done) {
|
||||||
const obj = new Parse.Object('TestObject');
|
const obj = new Parse.Object('TestObject');
|
||||||
obj.set('foo', null);
|
obj.set('foo', null);
|
||||||
obj.save().then(
|
obj.save().then(
|
||||||
@@ -232,7 +232,7 @@ describe('Parse.Object testing', () => {
|
|||||||
equal(obj.get('foo'), null);
|
equal(obj.get('foo'), null);
|
||||||
});
|
});
|
||||||
on_db('postgres', () => {
|
on_db('postgres', () => {
|
||||||
fail('should not succeed');
|
equal(obj.get('foo'), null);
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const TestObject = Parse.Object.extend('TestObject');
|
const TestObject = Parse.Object.extend('TestObject');
|
||||||
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter').default;
|
|
||||||
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
|
|
||||||
const request = require('../lib/request');
|
const request = require('../lib/request');
|
||||||
|
const TestUtils = require('../lib/TestUtils');
|
||||||
const defaultHeaders = {
|
const defaultHeaders = {
|
||||||
'X-Parse-Application-Id': 'test',
|
'X-Parse-Application-Id': 'test',
|
||||||
'X-Parse-Rest-API-Key': 'rest',
|
'X-Parse-Rest-API-Key': 'rest',
|
||||||
@@ -210,7 +209,7 @@ describe('Parse.Polygon testing', () => {
|
|||||||
|
|
||||||
describe('with location', () => {
|
describe('with location', () => {
|
||||||
if (process.env.PARSE_SERVER_TEST_DB !== 'postgres') {
|
if (process.env.PARSE_SERVER_TEST_DB !== 'postgres') {
|
||||||
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
|
beforeEach(async () => await TestUtils.destroyAllDataPermanently());
|
||||||
}
|
}
|
||||||
|
|
||||||
it('polygonContain query', done => {
|
it('polygonContain query', done => {
|
||||||
@@ -425,7 +424,15 @@ describe('Parse.Polygon testing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe_only_db('mongo')('Parse.Polygon testing', () => {
|
describe_only_db('mongo')('Parse.Polygon testing', () => {
|
||||||
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
|
const Config = require('../lib/Config');
|
||||||
|
let config;
|
||||||
|
beforeEach(async () => {
|
||||||
|
if (process.env.PARSE_SERVER_TEST_DB !== 'postgres') {
|
||||||
|
await TestUtils.destroyAllDataPermanently();
|
||||||
|
}
|
||||||
|
config = Config.get('test');
|
||||||
|
config.schemaCache.clear();
|
||||||
|
});
|
||||||
it('support 2d and 2dsphere', done => {
|
it('support 2d and 2dsphere', done => {
|
||||||
const coords = [
|
const coords = [
|
||||||
[0, 0],
|
[0, 0],
|
||||||
@@ -437,7 +444,7 @@ describe_only_db('mongo')('Parse.Polygon testing', () => {
|
|||||||
// testings against REST API, use raw formats
|
// testings against REST API, use raw formats
|
||||||
const polygon = { __type: 'Polygon', coordinates: coords };
|
const polygon = { __type: 'Polygon', coordinates: coords };
|
||||||
const location = { __type: 'GeoPoint', latitude: 10, longitude: 10 };
|
const location = { __type: 'GeoPoint', latitude: 10, longitude: 10 };
|
||||||
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
|
const databaseAdapter = config.database.adapter;
|
||||||
return reconfigureServer({
|
return reconfigureServer({
|
||||||
appId: 'test',
|
appId: 'test',
|
||||||
restAPIKey: 'rest',
|
restAPIKey: 'rest',
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ describe('Parse.Relation testing', () => {
|
|||||||
.then(done, done.fail);
|
.then(done, done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
it_exclude_dbs(['postgres'])('queries with relations', async () => {
|
it('queries with relations', async () => {
|
||||||
const ChildObject = Parse.Object.extend('ChildObject');
|
const ChildObject = Parse.Object.extend('ChildObject');
|
||||||
const childObjects = [];
|
const childObjects = [];
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
@@ -283,7 +283,7 @@ describe('Parse.Relation testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it_exclude_dbs(['postgres'])('query on pointer and relation fields with equal', done => {
|
it('query on pointer and relation fields with equal', done => {
|
||||||
const ChildObject = Parse.Object.extend('ChildObject');
|
const ChildObject = Parse.Object.extend('ChildObject');
|
||||||
const childObjects = [];
|
const childObjects = [];
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
@@ -366,7 +366,7 @@ describe('Parse.Relation testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it_exclude_dbs(['postgres'])('or queries on pointer and relation fields', done => {
|
it('or queries on pointer and relation fields', done => {
|
||||||
const ChildObject = Parse.Object.extend('ChildObject');
|
const ChildObject = Parse.Object.extend('ChildObject');
|
||||||
const childObjects = [];
|
const childObjects = [];
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
const Config = require('../lib/Config');
|
const Config = require('../lib/Config');
|
||||||
const MongoStorageAdapter = require('../lib/Adapters/Storage/Mongo/MongoStorageAdapter').default;
|
|
||||||
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
|
|
||||||
|
|
||||||
describe_only_db('mongo')('Schema Performance', function () {
|
describe('Schema Performance', function () {
|
||||||
let getAllSpy;
|
let getAllSpy;
|
||||||
let config;
|
let config;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
config = Config.get('test');
|
config = Config.get('test');
|
||||||
config.schemaCache.clear();
|
config.schemaCache.clear();
|
||||||
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
|
const databaseAdapter = config.database.adapter;
|
||||||
await reconfigureServer({ databaseAdapter });
|
await reconfigureServer({ databaseAdapter });
|
||||||
getAllSpy = spyOn(databaseAdapter, 'getAllClasses').and.callThrough();
|
getAllSpy = spyOn(databaseAdapter, 'getAllClasses').and.callThrough();
|
||||||
});
|
});
|
||||||
@@ -204,6 +202,6 @@ describe_only_db('mongo')('Schema Performance', function () {
|
|||||||
{},
|
{},
|
||||||
config.database
|
config.database
|
||||||
);
|
);
|
||||||
expect(getAllSpy.calls.count()).toBe(0);
|
expect(getAllSpy.calls.count()).toBe(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user