Replace server test with multilayer one

This commit is contained in:
Raul Ochoa
2015-03-30 12:32:09 +02:00
parent ada616ee6a
commit e7544e84c2
2 changed files with 56 additions and 13 deletions
+56
View File
@@ -0,0 +1,56 @@
require(__dirname + '/../support/test_helper');
var assert = require('../support/assert');
var redis = require('redis');
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
describe('tests from old api translated to multilayer', function() {
var layergroupUrl = '/api/v1/map';
var redisClient = redis.createClient(global.environment.redis.port);
after(function(done) {
// This test will add map_style records, like
// 'map_style|null|publicuser|my_table',
redisClient.keys("map_style|*", function(err, matches) {
redisClient.del(matches, function() {
done();
});
});
});
test("layergroup creation fails if CartoCSS is bogus", function(done) {
var layergroup = {
stat_tag: 'random_tag',
version: '1.0.0',
layers: [
{
type: 'mapnik',
options: {
sql: 'select 1 as cartodb_id, null::geometry as the_geom_webmercator',
cartocss: '#my_table3{',
cartocss_version: '2.0.1'
}
}
]
};
assert.response(server, {
url: layergroupUrl,
method: 'POST',
headers: {host: 'localhost', 'Content-Type': 'application/json' },
data: JSON.stringify(layergroup)
}, {}, function(res) {
assert.equal(res.statusCode, 400, res.body);
var parsed = JSON.parse(res.body);
assert.ok(parsed.errors[0].match(/^style0/));
assert.ok(parsed.errors[0].match(/missing closing/));
done();
});
});
});
-13
View File
@@ -121,19 +121,6 @@ suite.skip('server old_api', function() {
//
/////////////////////////////////////////////////////////////////////////////////
test("post'ing unparseable style returns 400 with error", function(done){
assert.response(server, {
url: '/tiles/my_table3/style?map_key=1234',
method: 'POST',
headers: {host: 'localhost', 'Content-Type': 'application/x-www-form-urlencoded' },
data: querystring.stringify({style: '#my_table3{'})
},{}, function(res) {
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
assert.ok( new RegExp(/missing closing/i).test(res.body) );
done();
});
});
test("post'ing multiple bad styles returns 400 with error array", function(done){
assert.response(server, {
url: '/tiles/my_table4/style?map_key=1234',