Files
kami-parse-server/spec/ParseServer.spec.js
Florent Vilmart 10631371e6 Introduces flow types for storage (#4349)
* Introduces flow types for storage

* Better typing of QueryOptions

* Adds flow types to SchemaCOntroller,

- runs flow on pre tests
- fixes flow

* Adds ClassLevelPermissions type

* Moves Controller types into a single file

* Changes import styles

* Changes import styles

* fixing method setIndexesWithSchemaFormat (#4454)

Fixing invalid database code in method `setIndexesWithSchemaFormat`:

* It must be a transaction, not a task, as it executes multiple database changes
* It should contain the initial queries inside the transaction, providing the context, not outside it;
* Replaced the code with the ES6 Generator notation
* Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters

* nits

* Fixes tests, improves flow typing
2017-12-30 20:44:18 -05:00

67 lines
1.9 KiB
JavaScript

'use strict';
/* Tests for ParseServer.js */
const express = require('express');
import MongoStorageAdapter from '../src/Adapters/Storage/Mongo/MongoStorageAdapter';
import PostgresStorageAdapter from '../src/Adapters/Storage/Postgres/PostgresStorageAdapter';
import ParseServer from '../src/ParseServer';
describe('Server Url Checks', () => {
const app = express();
app.get('/health', function(req, res){
res.json({
status: 'ok'
});
});
app.listen(13376);
it('validate good server url', (done) => {
Parse.serverURL = 'http://localhost:13376';
ParseServer.verifyServerUrl(function(result) {
if(!result) {
done.fail('Did not pass valid url');
}
done();
});
});
it('mark bad server url', (done) => {
Parse.serverURL = 'notavalidurl';
ParseServer.verifyServerUrl(function(result) {
if(result) {
done.fail('Did not mark invalid url');
}
done();
});
});
it('handleShutdown, close connection', (done) => {
const mongoURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase';
const postgresURI = 'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
let databaseAdapter;
if (process.env.PARSE_SERVER_TEST_DB === 'postgres') {
databaseAdapter = new PostgresStorageAdapter({
uri: process.env.PARSE_SERVER_TEST_DATABASE_URI || postgresURI,
collectionPrefix: 'test_',
});
} else {
databaseAdapter = new MongoStorageAdapter({
uri: mongoURI,
collectionPrefix: 'test_',
});
}
const newConfiguration = Object.assign({}, defaultConfiguration, { databaseAdapter });
const parseServer = ParseServer.start(newConfiguration, () => {
parseServer.handleShutdown();
parseServer.server.close((err) => {
if (err) {
done.fail('Close Server Error')
}
reconfigureServer({}).then(() => {
done();
});
});
});
});
});