2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 17:29:07 +08:00
|
|
|
require('../../support/test-helper');
|
2015-07-08 06:12:32 +08:00
|
|
|
|
|
|
|
var assert = require('assert');
|
2019-10-07 17:29:07 +08:00
|
|
|
var cartodbServer = require('../../../lib/server');
|
|
|
|
var serverOptions = require('../../../lib/server-options');
|
2015-07-08 06:12:32 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe('windshaft', function () {
|
|
|
|
it('should have valid global environment', function () {
|
2019-10-22 01:41:03 +08:00
|
|
|
assert.strictEqual(global.environment.name, 'test');
|
2015-07-08 06:12:32 +08:00
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('can instantiate a Windshaft object (configured express instance)', function () {
|
2015-07-08 06:12:32 +08:00
|
|
|
var ws = cartodbServer(serverOptions);
|
|
|
|
assert.ok(ws);
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('can spawn a new server on the global listen port', function (done) {
|
2015-07-08 06:12:32 +08:00
|
|
|
var ws = cartodbServer(serverOptions);
|
2019-10-22 01:07:24 +08:00
|
|
|
var server = ws.listen(global.environment.port, function () {
|
2015-07-08 06:12:32 +08:00
|
|
|
assert.ok(ws);
|
2015-09-17 06:19:00 +08:00
|
|
|
server.close(done); /* allow proper tear down */
|
2015-07-08 06:12:32 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('throws exception if incorrect options passed in', function () {
|
2015-07-08 06:12:32 +08:00
|
|
|
assert.throws(
|
2019-10-22 01:07:24 +08:00
|
|
|
function () {
|
|
|
|
var ws = cartodbServer({ unbuffered_logging: true });
|
2015-07-08 06:12:32 +08:00
|
|
|
ws.listen();
|
2018-04-03 01:02:31 +08:00
|
|
|
}, /Must initialise server with/
|
2015-07-08 06:12:32 +08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|