From 0abd6a2293657f6ec1609d3abd83da08961ca3f2 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Fri, 23 Jan 2015 17:02:13 +0100 Subject: [PATCH] Adds check for surrogate key headers in template instances p.s. it fixes instantiate template with params test --- test/acceptance/templates.js | 11 ++++++++--- test/support/test_helper.js | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/acceptance/templates.js b/test/acceptance/templates.js index ced90a40..3a8c2f42 100644 --- a/test/acceptance/templates.js +++ b/test/acceptance/templates.js @@ -5,6 +5,7 @@ var querystring = require('querystring'); var semver = require('semver'); var Step = require('step'); var strftime = require('strftime'); +var NamedMapsCacheEntry = require(__dirname + '/../../lib/cartodb/cache/model/named_maps_entry'); var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); var redis_stats_db = 5; @@ -1590,6 +1591,7 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // See https://github.com/CartoDB/Windshaft-cartodb/issues/176 helper.checkCache(res); + helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance_open.name).key()); return null; }, function finish(err) { @@ -1605,10 +1607,9 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio version: '0.0.1', name: 'acceptance_open_jsonp_params', auth: { method: 'open' }, - /* placeholders: { color: { type: "css_color", default: "red" } - },*/ + }, layergroup: { version: '1.0.0', layers: [ @@ -1661,9 +1662,11 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio function checkInstanciation(err, res) { if ( err ) throw err; + console.log(err, res.body, res.headers); assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); // See https://github.com/CartoDB/Windshaft-cartodb/issues/176 - helper.checkNoCache(res); + helper.checkCache(res); + helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance_open.name).key()); return null; }, function finish(err) { @@ -1845,6 +1848,7 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio assert.ok(parsed.hasOwnProperty('layergroupid'), "Missing 'layergroupid' from response body: " + res.body); layergroupid = parsed.layergroupid; + helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance2.name).key()); return null; }, function updateTemplate(err, res) @@ -1889,6 +1893,7 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio assert.ok(parsed.hasOwnProperty('layergroupid'), "Missing 'layergroupid' from response body: " + res.body); assert.ok(layergroupid != parsed.layergroupid); + helper.checkSurrogateKey(res, new NamedMapsCacheEntry('localhost', template_acceptance2.name).key()); return null; }, function finish(err) { diff --git a/test/support/test_helper.js b/test/support/test_helper.js index c040b552..9b4f0631 100644 --- a/test/support/test_helper.js +++ b/test/support/test_helper.js @@ -50,10 +50,16 @@ function checkCache(res) { assert.ok(res.headers.hasOwnProperty('last-modified')); } +function checkSurrogateKey(res, expectedKey) { + assert.ok(res.headers.hasOwnProperty('surrogate-key')); + assert.equal(res.headers['surrogate-key'], expectedKey); +} + module.exports = { lzma_compress_to_base64: lzma_compress_to_base64, checkNoCache: checkNoCache, + checkSurrogateKey: checkSurrogateKey, checkCache: checkCache };