Permalink
Browse files

Added close/disconnect methods

  • Loading branch information...
1 parent 99fdf56 commit 4e2edb46f58ae896b89da2afd9966e07c53a4865 @ryanrolds committed Mar 12, 2012
View
@@ -15,7 +15,7 @@ module.exports = (function() {
namespace = defaultNamespace;
}
- var app = express.createServer();
+ var app = this.app = express.createServer();
var agg = new Aggregator(app, key, namespace);
// Routes
@@ -25,6 +25,10 @@ module.exports = (function() {
app.listen(port, callback);
};
+ Server.prototype.close = function() {
+ this.app.close();
+ };
+
return Server;
})();
@@ -23,6 +23,10 @@ describe('aggregator', function() {
});
});
+ after(function(done) {
+ testHelpers.afterAggregator(aggregator, collector, monitor, done);
+ });
+
it('should support watching accesslog', function(done) {
var data = {
'hostname': os.hostname(),
@@ -63,5 +63,9 @@ module.exports = function() {
this.conn.emit('unwatch', data, callback);
};
+ MockMonitor.prototype.disconnect = function() {
+ this.conn.disconnect();
+ };
+
return MockMonitor;
}();
@@ -22,6 +22,13 @@ module.exports.writeToFile = function(file, text) {
});
};
+module.exports.afterAggregator = function(agg, coll, mon, callback) {
+ mon.disconnect();
+ coll.disconnect();
+ agg.close();
+ callback();
+};
+
module.exports.beforeAggregator = function(port, watchables, key, namespace, callback) {
var url = ['http://localhost:', port, '/', namespace].join('');
async.waterfall(
@@ -87,5 +87,9 @@ module.exports = function() {
});
};
+ Collector.prototype.disconnect = function() {
+ this.conn.disconnect();
+ };
+
return Collector;
}();

0 comments on commit 4e2edb4

Please sign in to comment.