improves test performance on mongodb (#4862)
* improves test performance on mongodb * Removes unused methdos
This commit is contained in:
@@ -8,35 +8,45 @@ const httpRequest = require("../src/cloud-code/httpRequest"),
|
||||
const port = 13371;
|
||||
const httpRequestServer = "http://localhost:" + port;
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.json({ 'type': '*/*' }));
|
||||
app.get("/hello", function(req, res){
|
||||
res.json({response: "OK"});
|
||||
});
|
||||
function startServer(done) {
|
||||
const app = express();
|
||||
app.use(bodyParser.json({ 'type': '*/*' }));
|
||||
app.get("/hello", function(req, res){
|
||||
res.json({response: "OK"});
|
||||
});
|
||||
|
||||
app.get("/404", function(req, res){
|
||||
res.status(404);
|
||||
res.send("NO");
|
||||
});
|
||||
app.get("/404", function(req, res){
|
||||
res.status(404);
|
||||
res.send("NO");
|
||||
});
|
||||
|
||||
app.get("/301", function(req, res){
|
||||
res.status(301);
|
||||
res.location("/hello");
|
||||
res.send();
|
||||
});
|
||||
app.get("/301", function(req, res){
|
||||
res.status(301);
|
||||
res.location("/hello");
|
||||
res.send();
|
||||
});
|
||||
|
||||
app.post('/echo', function(req, res){
|
||||
res.json(req.body);
|
||||
});
|
||||
app.post('/echo', function(req, res){
|
||||
res.json(req.body);
|
||||
});
|
||||
|
||||
app.get('/qs', function(req, res){
|
||||
res.json(req.query);
|
||||
});
|
||||
|
||||
app.listen(13371);
|
||||
app.get('/qs', function(req, res){
|
||||
res.json(req.query);
|
||||
});
|
||||
|
||||
return app.listen(13371, undefined, done);
|
||||
}
|
||||
|
||||
describe("httpRequest", () => {
|
||||
let server;
|
||||
beforeAll((done) => {
|
||||
server = startServer(done);
|
||||
});
|
||||
|
||||
afterAll((done) => {
|
||||
server.close(done);
|
||||
});
|
||||
|
||||
it("should do /hello", (done) => {
|
||||
httpRequest({
|
||||
url: httpRequestServer + "/hello"
|
||||
|
||||
@@ -9,7 +9,7 @@ const databaseURI = 'mongodb://localhost:27017/parseServerMongoAdapterTestDataba
|
||||
describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
beforeEach(done => {
|
||||
new MongoStorageAdapter({ uri: databaseURI })
|
||||
.deleteAllClasses()
|
||||
.dropDatabase()
|
||||
.then(done, fail);
|
||||
});
|
||||
|
||||
|
||||
@@ -10,11 +10,19 @@ const port = 12345;
|
||||
const hookServerURL = "http://localhost:" + port;
|
||||
const AppCache = require('../src/cache').AppCache;
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.json({ 'type': '*/*' }))
|
||||
app.listen(12345);
|
||||
|
||||
describe('Hooks', () => {
|
||||
let server;
|
||||
let app;
|
||||
beforeAll((done) => {
|
||||
app = express();
|
||||
app.use(bodyParser.json({ 'type': '*/*' }))
|
||||
server = app.listen(12345, undefined, done);
|
||||
});
|
||||
|
||||
afterAll((done) => {
|
||||
server.close(done);
|
||||
});
|
||||
|
||||
it("should have no hooks registered", (done) => {
|
||||
Parse.Hooks.getFunctions().then((res) => {
|
||||
expect(res.constructor).toBe(Array.prototype.constructor);
|
||||
|
||||
@@ -7,13 +7,20 @@ import ParseServer from '../src/ParseServer';
|
||||
|
||||
describe('Server Url Checks', () => {
|
||||
|
||||
const app = express();
|
||||
app.get('/health', function(req, res){
|
||||
res.json({
|
||||
status: 'ok'
|
||||
let server;
|
||||
beforeAll((done) => {
|
||||
const app = express();
|
||||
app.get('/health', function(req, res){
|
||||
res.json({
|
||||
status: 'ok'
|
||||
});
|
||||
});
|
||||
server = app.listen(13376, undefined, done);
|
||||
});
|
||||
|
||||
afterAll((done) => {
|
||||
server.close(done);
|
||||
});
|
||||
app.listen(13376);
|
||||
|
||||
it('validate good server url', (done) => {
|
||||
Parse.serverURL = 'http://localhost:13376';
|
||||
|
||||
@@ -12,7 +12,7 @@ const dropTable = (client, className) => {
|
||||
describe_only_db('postgres')('PostgresStorageAdapter', () => {
|
||||
const adapter = new PostgresStorageAdapter({ uri: databaseURI })
|
||||
beforeEach(() => {
|
||||
return adapter.deleteAllClasses();
|
||||
return adapter.dropDatabase();
|
||||
});
|
||||
|
||||
it('schemaUpgrade, upgrade the database schema when schema changes', done => {
|
||||
|
||||
@@ -411,17 +411,25 @@ global.jfail = function(err) {
|
||||
|
||||
global.it_exclude_dbs = excluded => {
|
||||
if (excluded.indexOf(process.env.PARSE_SERVER_TEST_DB) >= 0) {
|
||||
return xit;
|
||||
return (name, suite) => {
|
||||
return xit(`[${excluded}] ${name}`, suite);
|
||||
};
|
||||
} else {
|
||||
return it;
|
||||
return (name, suite) => {
|
||||
return it(`[${excluded}] ${name}`, suite);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
global.it_only_db = db => {
|
||||
if (process.env.PARSE_SERVER_TEST_DB === db) {
|
||||
return it;
|
||||
return (name, suite) => {
|
||||
return it(`[${db}] ${name}`, suite);
|
||||
};
|
||||
} else {
|
||||
return xit;
|
||||
return (name, suite) => {
|
||||
return xit(`[${db}] ${name}`, suite);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -435,11 +443,17 @@ global.fit_exclude_dbs = excluded => {
|
||||
|
||||
global.describe_only_db = db => {
|
||||
if (process.env.PARSE_SERVER_TEST_DB == db) {
|
||||
return describe;
|
||||
return (name, suite) => {
|
||||
return describe(`[${db}] ${name}`, suite);
|
||||
};
|
||||
} else if (!process.env.PARSE_SERVER_TEST_DB && db == 'mongo') {
|
||||
return describe;
|
||||
return (name, suite) => {
|
||||
return describe(`[${db}] ${name}`, suite);
|
||||
};
|
||||
} else {
|
||||
return () => {};
|
||||
return (name, suite) => {
|
||||
return xdescribe(`[${db}] ${name}`, suite);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user