Port tests to mocha (closes #20)

This commit is contained in:
Sandro Santilli
2012-07-09 16:49:31 +02:00
parent e45d8339c4
commit 2b24e46f6c
5 changed files with 573 additions and 233 deletions
+15 -11
View File
@@ -1,4 +1,4 @@
var assert = require('assert');
var assert = require('../support/assert');
var net = require('net');
require(__dirname + '/../test_helper');
var CacheValidator = require(__dirname + '/../../lib/cartodb/cache_validator');
@@ -27,14 +27,18 @@ function VarnishEmu(on_cmd_recieved, test_callback) {
});
}
tests['should call purge on varnish when invalidate database'] = function() {
var varnish = new VarnishEmu(
function(cmds) {
assert.ok(cmds.length == 1);
assert.equal('purge obj.http.X-Cache-Channel ~ \"^test_db:(.*test_cache.*)|(table)$\"\n', cmds[0].toString('utf8'));
},
function(){
CacheValidator.init('localhost', 1337);
CacheValidator.invalidate_db('test_db', 'test_cache');
suite('cache_validator', function() {
test('should call purge on varnish when invalidate database', function(done) {
var varnish = new VarnishEmu(function(cmds) {
assert.ok(cmds.length == 1);
assert.equal('purge obj.http.X-Cache-Channel ~ \"^test_db:(.*test_cache.*)|(table)$\"\n', cmds[0].toString('utf8'));
done();
},
function() {
CacheValidator.init('localhost', 1337);
CacheValidator.invalidate_db('test_db', 'test_cache');
});
});
}
});