From 61dbe15dee0b8163e20ccb1ef53b04dca324a275 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 10 Sep 2012 16:39:58 +0200 Subject: [PATCH] Put VarnishEmu in its own module --- test/acceptance/cache_validator.js | 25 +------------------------ test/support/VarnishEmu.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 test/support/VarnishEmu.js diff --git a/test/acceptance/cache_validator.js b/test/acceptance/cache_validator.js index 06a5ba3d..79939740 100644 --- a/test/acceptance/cache_validator.js +++ b/test/acceptance/cache_validator.js @@ -1,31 +1,8 @@ var assert = require('../support/assert'); -var net = require('net'); require(__dirname + '/../support/test_helper'); var CacheValidator = require(__dirname + '/../../lib/cartodb/cache_validator'); -var tests = module.exports = {}; -function VarnishEmu(on_cmd_recieved, test_callback) { - var self = this; - var welcome_msg = 'hi, im a varnish emu, right?'; - - self.commands_recieved = []; - - var server = net.createServer(function (socket) { - var command = ''; - socket.write("200 " + welcome_msg.length + "\n"); - socket.write(welcome_msg); - socket.on('data', function(data) { - self.commands_recieved.push(data); - on_cmd_recieved && on_cmd_recieved(self.commands_recieved); - socket.write('200 0\n'); - }); - }); - server.listen(1337, "127.0.0.1"); - - server.on('listening', function(){ - test_callback(); - }); -} +var VarnishEmu = require('../support/VarnishEmu'); suite('cache_validator', function() { diff --git a/test/support/VarnishEmu.js b/test/support/VarnishEmu.js new file mode 100644 index 00000000..6cd636d0 --- /dev/null +++ b/test/support/VarnishEmu.js @@ -0,0 +1,25 @@ +var net = require('net'); + +module.exports = function(on_cmd_recieved, test_callback) { + var self = this; + var welcome_msg = 'hi, im a varnish emu, right?'; + + self.commands_recieved = []; + + var server = net.createServer(function (socket) { + var command = ''; + socket.write("200 " + welcome_msg.length + "\n"); + socket.write(welcome_msg); + socket.on('data', function(data) { + self.commands_recieved.push(data); + on_cmd_recieved && on_cmd_recieved(self.commands_recieved); + socket.write('200 0\n'); + }); + }); + server.listen(1337, "127.0.0.1"); + + server.on('listening', function(){ + test_callback(); + }); +}; +