From b45394985bdf205e7651f2a006ac2b565ab76674 Mon Sep 17 00:00:00 2001 From: Mateusz Moneta Date: Thu, 5 May 2016 16:04:52 +0200 Subject: [PATCH] Add test. --- test/server_tests.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/server_tests.js b/test/server_tests.js index b15e70d2..77bb7dac 100644 --- a/test/server_tests.js +++ b/test/server_tests.js @@ -1,5 +1,6 @@ var dgram = require('dgram'), - net = require('net'); + net = require('net'), + fs = require('fs'); var config = { address: '127.0.0.1', @@ -59,5 +60,24 @@ module.exports = { }); client.end(); }); + }, + unix_socket_data_received: function(test) { + test.expect(3); + var server = require('../servers/tcp'); + config.socket = './statsd_tmp.socket'; + var started = server.start(config, function (data, rinfo) { + test.equal(msg, data.toString()); + test.equal(msg.length, rinfo.size); + fs.unlinkSync(config.socket); + config.socket = undefined; + test.done(); + }); + + test.ok(started); + + var client = net.connect(config.socket, function () { + client.write(msg); + client.end(); + }); } -} +};