From 788de0cac3e818328e3f6fcd889f6b2a6ea2a6ad Mon Sep 17 00:00:00 2001 From: Arif Amirani Date: Thu, 12 Jan 2012 14:52:55 +0530 Subject: [PATCH] Added basic tests for gelf appender --- test/gelfAppender.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/gelfAppender.js diff --git a/test/gelfAppender.js b/test/gelfAppender.js new file mode 100644 index 0000000..331752b --- /dev/null +++ b/test/gelfAppender.js @@ -0,0 +1,31 @@ +var vows = require('vows') +, log4js = require('../lib/log4js') +, assert = require('assert') +, util = require('util') +, dgram = require("dgram"); + +log4js.configure({ "appenders": [{"type": "gelf"}] }, undefined); + +vows.describe('log4js gelfAppender').addBatch({ + + 'with default gelfAppender settings': { + topic: function() { + var logger = log4js.getLogger(); + + //Start local dgram server to act as GELF server + var server = dgram.createSocket("udp4"); + //Assert as soon as message arrives + server.on("message", this.callback); + //Send a fake message as soon as server is ready + server.on("listening", function () { + logger.info("This should be a packet of size 161 bytes at the server"); + }); + + //Listen on default values + server.bind(12201, 'localhost'); + }, + 'should receive log messages at the local gelf server': function(err, packet) { + assert.ok(packet.size > 0, "Recevied blank message"); + } + } +}).export(module); \ No newline at end of file