improves test performance on mongodb (#4862)

* improves test performance on mongodb

* Removes unused methdos
This commit is contained in:
Florent Vilmart
2018-06-29 17:09:51 -04:00
parent ec27bc7e8e
commit 7319aabf7a
10 changed files with 88 additions and 46 deletions

View File

@@ -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"