Skip to content

Commit

Permalink
Postgres exclude failing tests (#2081)
Browse files Browse the repository at this point in the history
* reload the right data

More passing postgres tests

Handle schema updates, and $in for non array columns

remove authdata from user and implement ensureUniqueness

Make some tests work, detect existing classes

Throw proper error for unique index violation

fix findOneAndUpdate

Support more types

support more type

Support boolean, fix _rperm/_wperm, add TODO

Support string types and also simplify tests

Move operator flattening into Parse Server and out of mongo adapters

Move authdata transform for create into Parse Server

Move authdata transforms completely in to Parse Server

Fix test setup

inline addSchema

Inject default schema to response from DB adapter

* Mark tests that don't work in Postgres

* Exclude one more test

* Exclude some more failing tests

* Exclude more tests
  • Loading branch information
drew-gross authored and flovilmart committed Jun 17, 2016
1 parent 7da4deb commit ab06055
Show file tree
Hide file tree
Showing 47 changed files with 811 additions and 795 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ env:
- MONGODB_VERSION=3.2.6
matrix:
fast_finish: true,
allow_failures:
- env: PARSE_SERVER_TEST_DB=postgres
branches:
only:
- master
Expand Down
1 change: 0 additions & 1 deletion spec/AdaptableController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ MockController.prototype = Object.create(AdaptableController.prototype);
MockController.prototype.constructor = AdaptableController;

describe("AdaptableController", ()=>{

it("should use the provided adapter", (done) => {
var adapter = new FilesAdapter();
var controller = new FilesController(adapter);
Expand Down
1 change: 0 additions & 1 deletion spec/CLI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var definitions = {
}

describe("commander additions", () => {

afterEach((done) => {
commander.options = [];
delete commander.arg0;
Expand Down
1 change: 0 additions & 1 deletion spec/Client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var Client = require('../src/LiveQuery/Client').Client;
var ParseWebSocket = require('../src/LiveQuery/ParseWebSocketServer').ParseWebSocket;

describe('Client', function() {

it('can be initialized', function() {
var parseWebSocket = new ParseWebSocket({});
var client = new Client(1, parseWebSocket);
Expand Down
1 change: 0 additions & 1 deletion spec/CloudCodeLogger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var LoggerController = require('../src/Controllers/LoggerController').LoggerCont
var FileLoggerAdapter = require('../src/Adapters/Logger/FileLoggerAdapter').FileLoggerAdapter;

describe("Cloud Code Logger", () => {

it("should expose log to functions", (done) => {
var logController = new LoggerController(new FileLoggerAdapter());

Expand Down
1 change: 0 additions & 1 deletion spec/EventEmitterPubSub.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var EventEmitterPubSub = require('../src/LiveQuery/EventEmitterPubSub').EventEmitterPubSub;

describe('EventEmitterPubSub', function() {

it('can publish and subscribe', function() {
var publisher = EventEmitterPubSub.createPublisher();
var subscriber = EventEmitterPubSub.createSubscriber();
Expand Down
3 changes: 0 additions & 3 deletions spec/FileLoggerAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var Parse = require('parse/node').Parse;
var request = require('request');

describe('info logs', () => {

it("Verify INFO logs", (done) => {
var fileLoggerAdapter = new FileLoggerAdapter();
fileLoggerAdapter.info('testing info logs', () => {
Expand All @@ -27,7 +26,6 @@ describe('info logs', () => {
});

describe('error logs', () => {

it("Verify ERROR logs", (done) => {
var fileLoggerAdapter = new FileLoggerAdapter();
fileLoggerAdapter.error('testing error logs', () => {
Expand All @@ -50,7 +48,6 @@ describe('error logs', () => {
});

describe('verbose logs', () => {

it("mask sensitive information in _User class", (done) => {
reconfigureServer({ verbose: true })
.then(() => createTestUser())
Expand Down
37 changes: 18 additions & 19 deletions spec/HTTPRequest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ app.listen(13371);


describe("httpRequest", () => {

it("should do /hello", (done) => {
httpRequest({
url: httpRequestServer+"/hello"
Expand All @@ -51,7 +50,7 @@ describe("httpRequest", () => {
done();
})
});

it("should do /hello with callback and promises", (done) => {
var calls = 0;
httpRequest({
Expand All @@ -70,7 +69,7 @@ describe("httpRequest", () => {
done();
})
});

it("should do not follow redirects by default", (done) => {

httpRequest({
Expand All @@ -83,7 +82,7 @@ describe("httpRequest", () => {
done();
})
});

it("should follow redirects when set", (done) => {

httpRequest({
Expand All @@ -100,17 +99,17 @@ describe("httpRequest", () => {
done();
})
});

it("should fail on 404", (done) => {
var calls = 0;
httpRequest({
url: httpRequestServer+"/404",
success: function() {
success: function() {
calls++;
fail("should not succeed");
done();
},
error: function(httpResponse) {
error: function(httpResponse) {
calls++;
expect(calls).toBe(1);
expect(httpResponse.status).toBe(404);
Expand All @@ -121,7 +120,7 @@ describe("httpRequest", () => {
}
});
})

it("should fail on 404", (done) => {
httpRequest({
url: httpRequestServer+"/404",
Expand All @@ -136,7 +135,7 @@ describe("httpRequest", () => {
done();
})
})

it("should post on echo", (done) => {
var calls = 0;
httpRequest({
Expand All @@ -160,27 +159,27 @@ describe("httpRequest", () => {
done();
})
});

it("should encode a query string body by default", (done) => {
let options = {
body: {"foo": "bar"},
body: {"foo": "bar"},
}
let result = httpRequest.encodeBody(options);
expect(result.body).toEqual('foo=bar');
expect(result.headers['Content-Type']).toEqual('application/x-www-form-urlencoded');
done();

})

it("should encode a JSON body", (done) => {
let options = {
body: {"foo": "bar"},
body: {"foo": "bar"},
headers: {'Content-Type': 'application/json'}
}
let result = httpRequest.encodeBody(options);
expect(result.body).toEqual('{"foo":"bar"}');
done();

})
it("should encode a www-form body", (done) => {
let options = {
Expand All @@ -193,7 +192,7 @@ describe("httpRequest", () => {
});
it("should not encode a wrong content type", (done) => {
let options = {
body:{"foo": "bar", "bar": "baz"},
body:{"foo": "bar", "bar": "baz"},
headers: {'cOntent-tYpe': 'mime/jpeg'}
}
let result = httpRequest.encodeBody(options);
Expand All @@ -204,18 +203,18 @@ describe("httpRequest", () => {
it("should fail gracefully", (done) => {
httpRequest({
url: "http://not a good url",
success: function() {
success: function() {
fail("should not succeed");
done();
},
error: function(error) {
error: function(error) {
expect(error).not.toBeUndefined();
expect(error).not.toBeNull();
done();
}
});
});

it("should params object to query string", (done) => {
httpRequest({
url: httpRequestServer+"/qs",
Expand Down
4 changes: 2 additions & 2 deletions spec/InstallationsRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('InstallationsRouter', () => {
});
});

it('query installations with count = 1', (done) => {
it_exclude_dbs(['postgres'])('query installations with count = 1', (done) => {
var androidDeviceRequest = {
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
'deviceType': 'android'
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('InstallationsRouter', () => {
});
});

it('query installations with limit = 0 and count = 1', (done) => {
it_exclude_dbs(['postgres'])('query installations with limit = 0 and count = 1', (done) => {
var androidDeviceRequest = {
'installationId': '12345678-abcd-abcd-abcd-123456789abc',
'deviceType': 'android'
Expand Down
52 changes: 21 additions & 31 deletions spec/MongoTransform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ let dd = require('deep-diff');
let mongodb = require('mongodb');

describe('parseObjectToMongoObjectForCreate', () => {

it('a basic number', (done) => {
var input = {five: 5};
var output = transform.parseObjectToMongoObjectForCreate(null, input, {
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('parseObjectToMongoObjectForCreate', () => {

//TODO: object creation requests shouldn't be seeing __op delete, it makes no sense to
//have __op delete in a new object. Figure out what this should actually be testing.
notWorking('a delete op', (done) => {
xit('a delete op', (done) => {
var input = {deleteMe: {__op: 'Delete'}};
var output = transform.parseObjectToMongoObjectForCreate(null, input, { fields: {} });
jequal(output, {});
Expand All @@ -64,37 +63,33 @@ describe('parseObjectToMongoObjectForCreate', () => {
done();
});

describe('GeoPoints', () => {
it('plain', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, {location: geoPoint},{
fields: {location: {type: 'GeoPoint'}}
});
expect(out.location).toEqual([180, -180]);
done();
it('plain', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, {location: geoPoint},{
fields: {location: {type: 'GeoPoint'}}
});
expect(out.location).toEqual([180, -180]);
done();
});

it('in array', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, {locations: [geoPoint, geoPoint]},{
fields: {locations: {type: 'Array'}}
});
expect(out.locations).toEqual([geoPoint, geoPoint]);
done();
it('in array', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, {locations: [geoPoint, geoPoint]},{
fields: {locations: {type: 'Array'}}
});
expect(out.locations).toEqual([geoPoint, geoPoint]);
done();
});

it('in sub-object', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, { locations: { start: geoPoint }},{
fields: {locations: {type: 'Object'}}
});
expect(out).toEqual({ locations: { start: geoPoint } });
done();
it('in sub-object', (done) => {
var geoPoint = {__type: 'GeoPoint', longitude: 180, latitude: -180};
var out = transform.parseObjectToMongoObjectForCreate(null, { locations: { start: geoPoint }},{
fields: {locations: {type: 'Object'}}
});
expect(out).toEqual({ locations: { start: geoPoint } });
done();
});
});

describe('transformWhere', () => {
it('objectId', (done) => {
var out = transform.transformWhere(null, {objectId: 'foo'});
expect(out._id).toEqual('foo');
Expand All @@ -109,9 +104,7 @@ describe('transformWhere', () => {
jequal(input.objectId, output._id);
done();
});
});

describe('mongoObjectToParseObject', () => {
it('built-in timestamps', (done) => {
var input = {createdAt: new Date(), updatedAt: new Date()};
var output = transform.mongoObjectToParseObject(null, input, { fields: {} });
Expand Down Expand Up @@ -191,9 +184,6 @@ describe('mongoObjectToParseObject', () => {
expect(dd(output, input)).toEqual(undefined);
done();
});
});

describe('transform schema key changes', () => {

it('changes new pointer key', (done) => {
var input = {
Expand Down
41 changes: 19 additions & 22 deletions spec/OAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var Config = require("../src/Config");
var defaultColumns = require('../src/Controllers/SchemaController').defaultColumns;

describe('OAuth', function() {

it("Nonce should have right length", (done) => {
jequal(OAuth.nonce().length, 30);
done();
Expand Down Expand Up @@ -218,29 +217,27 @@ describe('OAuth', function() {
return request.post(options, callback);
}

it("should create user with REST API", (done) => {

it_exclude_dbs(['postgres'])("should create user with REST API", done => {
createOAuthUser((error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
ok(b.sessionToken);
expect(b.objectId).not.toBeNull();
expect(b.objectId).not.toBeUndefined();
var sessionToken = b.sessionToken;
var q = new Parse.Query("_Session");
q.equalTo('sessionToken', sessionToken);
q.first({useMasterKey: true}).then((res) => {
expect(res.get("installationId")).toEqual('yolo');
done();
}).fail((err) => {
fail('should not fail fetching the session');
done();
})
});

expect(error).toBe(null);
var b = JSON.parse(body);
ok(b.sessionToken);
expect(b.objectId).not.toBeNull();
expect(b.objectId).not.toBeUndefined();
var sessionToken = b.sessionToken;
var q = new Parse.Query("_Session");
q.equalTo('sessionToken', sessionToken);
q.first({useMasterKey: true}).then((res) => {
expect(res.get("installationId")).toEqual('yolo');
done();
}).fail((err) => {
fail('should not fail fetching the session');
done();
})
});
});

it("should only create a single user with REST API", (done) => {
it_exclude_dbs(['postgres'])("should only create a single user with REST API", (done) => {
var objectId;
createOAuthUser((error, response, body) => {
expect(error).toBe(null);
Expand All @@ -260,7 +257,7 @@ describe('OAuth', function() {
});
});

it("unlink and link with custom provider", (done) => {
it_exclude_dbs(['postgres'])("unlink and link with custom provider", (done) => {
var provider = getMockMyOauthProvider();
Parse.User._registerAuthenticationProvider(provider);
Parse.User._logInWith("myoauth", {
Expand Down
Loading

0 comments on commit ab06055

Please sign in to comment.