fixed tests
This commit is contained in:
+30
-17
@@ -16,7 +16,7 @@ var cached_server = new CartodbWindshaft(serverOptions);
|
||||
|
||||
tests["first time a tile is request should not be cached"] = function() {
|
||||
assert.response(cached_server, {
|
||||
url: '/tiles/gadm4/6/31/24.png?geom_type=polygon',
|
||||
url: '/tiles/test_table_2/6/31/24.png?geom_type=polygon',
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
@@ -33,17 +33,17 @@ tests["first time a tile is request should not be cached"] = function() {
|
||||
tests["second time a tile is request should be cached"] = function() {
|
||||
|
||||
var cached_server2 = new CartodbWindshaft(serverOptions);
|
||||
var url= '/tiles/gadm4/6/31/24.png';
|
||||
var url= '/tiles/test_table_2/6/31/24.png';
|
||||
assert.response(cached_server2, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
}, function(res) {
|
||||
assert.response(cached_server2, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
@@ -57,21 +57,21 @@ tests["second time a tile is request should be cached"] = function() {
|
||||
|
||||
tests["LRU tile should be removed"] = function() {
|
||||
|
||||
var urls = ['/tiles/gadm4/6/31/24.png',
|
||||
'/tiles/gadm4/6/31/25.png',
|
||||
'/tiles/gadm4/6/31/26.png',
|
||||
'/tiles/gadm4/6/31/27.png'];
|
||||
var urls = ['/tiles/test_table_2/6/31/24.png',
|
||||
'/tiles/test_table_2/6/31/25.png',
|
||||
'/tiles/test_table_2/6/31/26.png',
|
||||
'/tiles/test_table_2/6/31/27.png'];
|
||||
|
||||
//create another server to not take previos test stats into account
|
||||
var so = _.clone(serverOptions);
|
||||
_(so).extend({lru_cache: true, lru_cache_size: 3});
|
||||
var so = _.clone(serverOptions);
|
||||
_(so).extend({lru_cache: true, lru_cache_size: 3});
|
||||
|
||||
var _cached_server = new CartodbWindshaft(so);
|
||||
|
||||
function makeReq(url, callback) {
|
||||
assert.response(_cached_server, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
@@ -93,7 +93,7 @@ tests["LRU tile should be removed"] = function() {
|
||||
}, function() {
|
||||
assert.response(_cached_server, {
|
||||
url: urls[0],
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
@@ -112,19 +112,19 @@ tests["LRU tile should be removed"] = function() {
|
||||
|
||||
tests["cache should be invalidated"] = function() {
|
||||
|
||||
var url = '/tiles/gadm4/6/29/27.png';
|
||||
var url = '/tiles/test_table_2/6/29/27.png';
|
||||
var cache = CacheValidator(global.environment.redis);
|
||||
assert.response(cached_server, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
}, function(res) {
|
||||
cache.setTimestamp('cartodb_dev_user_3_db', 'gadm4', (new Date().getTime()/1000.0)+100, function() {
|
||||
cache.setTimestamp('windshaft_test', 'test_table_2', (new Date().getTime()/1000.0)+100, function() {
|
||||
assert.response(cached_server, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
@@ -134,5 +134,18 @@ tests["cache should be invalidated"] = function() {
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
tests["Last-Modified header should be sent"] = function() {
|
||||
var cached_server2 = new CartodbWindshaft(serverOptions);
|
||||
var url= '/tiles/test_table_2/6/31/24.png';
|
||||
assert.response(cached_server2, {
|
||||
url: url,
|
||||
headers: {host: 'vizzuality.localhost.lan'},
|
||||
method: 'GET'
|
||||
},{
|
||||
status: 200
|
||||
}, function(res) {
|
||||
assert.ok(res.header('Last-Modified') !== undefined);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user