Permalink
Browse files

Adding parse tests for other formats.

  • Loading branch information...
1 parent 2dcb57f commit 0953d888a177e177d15aaed36c5ef61f10975646 @squeeks committed Mar 3, 2013
Showing with 42 additions and 5 deletions.
  1. +13 −5 test/parse-3164.js
  2. +14 −0 test/parse-5424.js
  3. +15 −0 test/parse-5848.js
View
@@ -6,15 +6,23 @@ assert.ok(syslogParser, 'parser loaded');
var messages = JSON.parse(fs.readFileSync(__dirname + '/fixtures/RFC3164.json', 'utf8'));
-
for(message in messages) {
parsed = syslogParser.parse(messages[message]);
assert.ok(parsed);
};
-// TODO Go through each message per fixture, validate ALL values.
+syslogParser.parse(messages[0], function(parsedMessage){
+ var expectedData = {
+ originalMessage: '<13>Feb 5 17:32:18 10.0.0.99 Use the BFG!',
+ prival: 13,
+ facilityID: 1,
+ severityID: 5,
+ facility: 'user',
+ severity: 'notice',
+ type: 'RFC3164',
+ time: new Date('Tue Feb 05 2013 17:32:18 GMT+0000'),
+ host: '10.0.0.99',
+ message: 'Use the BFG!' };
-syslogParser.parse(messages[0], function(rfc3164BeforeTenth){
- assert.ok(rfc3164BeforeTenth, 'RFC 3164 record parsed.');
- assert.equal(rfc3164BeforeTenth.host, '10.0.0.99');
+ assert.deepEqual(parsedMessage, expectedData);
});
View
@@ -0,0 +1,14 @@
+var syslogParser = require('../lib/glossy/parse.js'),
+ assert = require('assert'),
+ fs = require('fs');
+
+assert.ok(syslogParser, 'parser loaded');
+
+var messages = JSON.parse(fs.readFileSync(__dirname + '/fixtures/RFC5424.json', 'utf8'));
+
+for(message in messages) {
+ parsed = syslogParser.parse(messages[message]);
+ assert.ok(parsed);
+};
+
+//TODO expand tests further
View
@@ -0,0 +1,15 @@
+var syslogParser = require('../lib/glossy/parse.js'),
+ assert = require('assert'),
+ fs = require('fs');
+
+assert.ok(syslogParser, 'parser loaded');
+
+var messages = JSON.parse(fs.readFileSync(__dirname + '/fixtures/RFC5848.json', 'utf8'));
+
+for(message in messages) {
+ parsed = syslogParser.parse(messages[message]);
+ assert.ok(parsed);
+};
+
+//TODO expand tests further
+

0 comments on commit 0953d88

Please sign in to comment.