Skip to content

fix(package): update pg-promise to version 6.3.0 #3982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"parse-server-push-adapter": "1.3.0",
"parse-server-s3-adapter": "1.0.6",
"parse-server-simple-mailgun-adapter": "1.0.0",
"pg-promise": "5.9.7",
"pg-promise": "6.3.0",
"redis": "2.7.1",
"request": "2.81.0",
"semver": "5.3.0",
Expand Down
75 changes: 45 additions & 30 deletions spec/PostgresInitOptions.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const Parse = require('parse/node').Parse;
const PostgresStorageAdapter = require('../src/Adapters/Storage/Postgres/PostgresStorageAdapter');
const postgresURI = 'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
const Config = require('../src/Config');
const ParseServer = require("../src/index");
const express = require('express');
//public schema
const databaseOptions1 = {
initOptions: {
Expand All @@ -28,40 +29,54 @@ const GameScore = Parse.Object.extend({
className: "GameScore"
});

function createParseServer(options) {
return new Promise((resolve, reject) => {
const parseServer = new ParseServer.default(Object.assign({},
defaultConfiguration, options, {
serverURL: "http://localhost:12666/parse",
__indexBuildCompletionCallbackForTests: promise => {
promise
.then(() => {
expect(Parse.applicationId).toEqual("test");
var app = express();
app.use('/parse', parseServer.app);

const server = app.listen(12666);
Parse.serverURL = "http://localhost:12666/parse";
resolve(server);
}, reject);
}}));
});
}

describe_only_db('postgres')('Postgres database init options', () => {
let server;

afterEach(() => {
if (server) {
server.close();
}
})

it('should create server with public schema databaseOptions', (done) => {
const config = new Config('test');
// Close the current DB before continueing
config.database.adapter._pgp.end();
reconfigureServer({
databaseAdapter: new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions1
})
}).then(done, done.fail);
});
const adapter = new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions1
})

it("save new GameScore in public schema", function (done) {
var score = new GameScore({ "score": 1337, "playerName": "Sean Plott", "cheatMode": false });
score.save().then(done, done.fail);
createParseServer({ databaseAdapter: adapter }).then((newServer) => {
server = newServer;
var score = new GameScore({ "score": 1337, "playerName": "Sean Plott", "cheatMode": false });
return score.save();
}).then(done, done.fail);
});

it('should fail to create server if schema databaseOptions does not exist', (done) => {
const config = new Config('test');
// Close the current DB before continueing
config.database.adapter._pgp.end();
reconfigureServer({
databaseAdapter: new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions2
})
}).then(() => {
done.fail('Should not succeed');
}, error => {
// INVALID_SCHEMA error 3F000
// https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
expect(error.code).toEqual('3F000');
done();
});
const adapter = new PostgresStorageAdapter({
uri: postgresURI, collectionPrefix: 'test_',
databaseOptions: databaseOptions2
})

createParseServer({ databaseAdapter: adapter }).then(done.fail, done);
});
});
7 changes: 1 addition & 6 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,7 @@ beforeEach(done => {
Parse.initialize('test', 'test', 'test');
Parse.serverURL = 'http://localhost:' + port + '/1';
done();
}, () => {
Parse.initialize('test', 'test', 'test');
Parse.serverURL = 'http://localhost:' + port + '/1';
// fail(JSON.stringify(error));
done();
})
}).catch(done.fail);
});

afterEach(function(done) {
Expand Down