Windshaft-cartodb/test/acceptance/server.js

73 lines
2.4 KiB
JavaScript
Raw Normal View History

require('../support/test_helper');
2015-03-30 21:07:49 +08:00
2012-07-09 22:49:31 +08:00
var assert = require('../support/assert');
2011-09-05 07:00:41 +08:00
var querystring = require('querystring');
2015-03-23 19:40:24 +08:00
var step = require('step');
var CartodbWindshaft = require('../../lib/cartodb/server');
var serverOptions = require('../../lib/cartodb/server_options');
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
2011-09-05 07:00:41 +08:00
2015-03-24 02:28:34 +08:00
suite('server', function() {
2012-07-12 19:31:39 +08:00
2012-08-14 21:13:23 +08:00
// TODO: I guess this should be a 404 instead...
2012-07-09 22:49:31 +08:00
test("get call to server returns 200", function(done){
2015-03-23 19:40:24 +08:00
step(
function doGet() {
var next = this;
assert.response(server, {
url: '/',
method: 'GET'
},{}, function(res, err) { next(err,res); });
},
function doCheck(err, res) {
2015-07-15 21:03:28 +08:00
assert.ifError(err);
assert.ok(res.statusCode, 200);
var cc = res.headers['x-cache-channel'];
assert.ok(!cc);
return null;
},
function finish(err) {
done(err);
}
);
2012-07-09 22:49:31 +08:00
});
test("get call to server returns 200", function(done){
assert.response(server, {
url: '/version',
method: 'GET'
},{
status: 200
}, function(res) {
var parsed = JSON.parse(res.body);
assert.ok(parsed.hasOwnProperty('windshaft_cartodb'), "No 'windshaft_cartodb' version in " + parsed);
assert.ok(parsed.hasOwnProperty('windshaft'), "No 'windshaft' version in " + parsed);
assert.ok(parsed.hasOwnProperty('grainstore'), "No 'grainstore' version in " + parsed);
assert.ok(parsed.hasOwnProperty('node_mapnik'), "No 'node_mapnik' version in " + parsed);
assert.ok(parsed.hasOwnProperty('mapnik'), "No 'mapnik' version in " + parsed);
done();
});
});
2015-03-24 02:28:34 +08:00
});
suite('server old_api', function() {
// See https://github.com/CartoDB/Windshaft-cartodb/issues/115
test.skip("get'ing tile with not-strictly-valid style", function(done) {
var style = querystring.stringify({style: '#test_table{line-color:black}}', style_version: '2.0.0'});
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table/0/0/0.png?' + style, // madrid
method: 'GET',
encoding: 'binary'
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
done();
});
});
2012-07-09 22:49:31 +08:00
});