From 0a57e791d5a84752af7c468c378af89f95a0d607 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 5 Oct 2012 16:50:39 +0200 Subject: [PATCH] Add test for cache flushing (see #183) --- test/acceptance/server.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/acceptance/server.js b/test/acceptance/server.js index 6ad061ed..f182eba7 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -539,6 +539,42 @@ suite('server', function() { }); }); + ///////////////////////////////////////////////////////////////////////////////// + // + // DELETE CACHE + // + ///////////////////////////////////////////////////////////////////////////////// + + test("forbids flushing cache without specifying table name", function(done) { + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/flush_cache', + method: 'DELETE' + },{}, function(res) { + assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body); + done(); + }); + }); + + test("allows flushing table cache by unauthenticated user", function(done) { + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/gadm4/flush_cache', + method: 'DELETE' + },{}, function(res) { + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + // TODO: also check that varnish is signalled (using VarnishEmu) + // NOTE: requires enable_cache=1 in test.js + done(); + }); + }); + + ///////////////////////////////////////////////////////////////////////////////// + // + // Tear down + // + ///////////////////////////////////////////////////////////////////////////////// + suiteTeardown(function(done) { // This test will add map_style records, like // 'map_style|null|publicuser|my_table',