Added node modules
This commit is contained in:
		
							
								
								
									
										39
									
								
								node_modules/winston/test/transports/console-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								node_modules/winston/test/transports/console-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| /* | ||||
|  * console-test.js: Tests for instances of the Console transport | ||||
|  * | ||||
|  * (C) 2010 Charlie Robbins | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     assert = require('assert'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var npmTransport = new (winston.transports.Console)(), | ||||
|     syslogTransport = new (winston.transports.Console)({ levels: winston.config.syslog.levels }); | ||||
|  | ||||
| vows.describe('winston/transports/console').addBatch({ | ||||
|   "An instance of the Console Transport": { | ||||
|     "with npm levels": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertConsole(npmTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(npmTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     }, | ||||
|     "with syslog levels": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertConsole(syslogTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testSyslogLevels(syslogTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
							
								
								
									
										47
									
								
								node_modules/winston/test/transports/couchdb-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								node_modules/winston/test/transports/couchdb-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| /* | ||||
|  * couchdb-test.js: Tests for instances of the Couchdb transport | ||||
|  * | ||||
|  * (C) 2011 Max Ogden | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     fs = require('fs'), | ||||
|     http = require('http'), | ||||
|     assert = require('assert'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var couchdbTransport = new (winston.transports.Couchdb)({  | ||||
|   "host": "localhost", | ||||
|   "port": 1337, | ||||
|   "db": "logs" | ||||
| }); | ||||
|  | ||||
| var server = http.createServer(function (req, res) { | ||||
|   res.end(); | ||||
| }); | ||||
|  | ||||
| server.listen(1337); | ||||
|  | ||||
| vows.describe('winston/transports/couchdb').addBatch({ | ||||
|   "An instance of the Couchdb Transport": { | ||||
|     "when passed valid options": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertCouchdb(couchdbTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(couchdbTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }).addBatch({ | ||||
|   "When the tests are over": { | ||||
|     "the server should cleanup": function () { | ||||
|       server.close(); | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
							
								
								
									
										102
									
								
								node_modules/winston/test/transports/file-maxfiles-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								node_modules/winston/test/transports/file-maxfiles-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,102 @@ | ||||
| /* | ||||
|  * file-maxfiles-test.js: Tests for instances of the File transport setting the max file size, | ||||
|  * and setting a number for max files created. | ||||
|  * maxSize * maxFiles = total storage used by winston. | ||||
|  * | ||||
|  * (C) 2011 Daniel Aristizabal | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var assert = require('assert'), | ||||
|     exec = require('child_process').exec, | ||||
|     fs = require('fs'), | ||||
|     path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var maxfilesTransport = new winston.transports.File({ | ||||
|   timestamp: false, | ||||
|   json: false, | ||||
|   filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxfiles.log'), | ||||
|   maxsize: 4096, | ||||
|   maxFiles: 3 | ||||
| }); | ||||
|      | ||||
| vows.describe('winston/transports/file/maxfiles').addBatch({ | ||||
|   "An instance of the File Transport": { | ||||
|     "when passed a valid filename": { | ||||
|       topic: maxfilesTransport, | ||||
|       "should be a valid transporter": function (transportTest) { | ||||
|         helpers.assertFile(transportTest); | ||||
|       }, | ||||
|       "should set the maxFiles option correctly": function (transportTest) { | ||||
|         assert.isNumber(transportTest.maxFiles); | ||||
|       } | ||||
|     }, | ||||
|     "when delete old test files": { | ||||
|       topic: function () { | ||||
|         exec('rm -rf ' + path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxfiles*'), this.callback); | ||||
|       }, | ||||
|       "and when passed more files than the maxFiles": { | ||||
|         topic: function () { | ||||
|           var that = this, | ||||
|               created = 0; | ||||
|                | ||||
|           function data(ch) { | ||||
|             return new Array(1018).join(String.fromCharCode(65 + ch)); | ||||
|           }; | ||||
|        | ||||
|           function logKbytes(kbytes, txt) { | ||||
|             // | ||||
|             // With no timestamp and at the info level, | ||||
|             // winston adds exactly 7 characters:  | ||||
|             // [info](4)[ :](2)[\n](1) | ||||
|             // | ||||
|             for (var i = 0; i < kbytes; i++) { | ||||
|               maxfilesTransport.log('info', data(txt), null, function () { }); | ||||
|             } | ||||
|           } | ||||
|            | ||||
|           maxfilesTransport.on('logged', function () { | ||||
|             if (++created === 6) { | ||||
|               return that.callback(); | ||||
|             } | ||||
|              | ||||
|             logKbytes(4, created); | ||||
|           }); | ||||
|           | ||||
|           logKbytes(4, created); | ||||
|         }, | ||||
|         "should be only 3 files called 5.log, 4.log and 3.log": function () { | ||||
|           for (var num = 0; num < 6; num++) { | ||||
|             var file = !num ? 'testmaxfiles.log' : 'testmaxfiles' + num + '.log', | ||||
|                 fullpath = path.join(__dirname, '..', 'fixtures', 'logs', file); | ||||
|              | ||||
|             // There should be no files with that name | ||||
|             if (num >= 0 && num < 3) { | ||||
|               return assert.throws(function () { | ||||
|                 fs.statSync(file); | ||||
|               }, Error); | ||||
|             }  | ||||
|  | ||||
|             // The other files should be exist | ||||
|             assert.doesNotThrow(function () { | ||||
|               fs.statSync(file); | ||||
|             }, Error); | ||||
|           } | ||||
|         }, | ||||
|         "should have the correct content": function () { | ||||
|           ['D', 'E', 'F'].forEach(function (name, inx) { | ||||
|             var counter = inx + 3, | ||||
|                 logsDir = path.join(__dirname, '..', 'fixtures', 'logs'), | ||||
|                 content = fs.readFileSync(path.join(logsDir, 'testmaxfiles' + counter + '.log'), 'utf-8'); | ||||
|             // The content minus the 7 characters added by winston | ||||
|             assert.lengthOf(content.match(new RegExp(name, 'g')), 4068); | ||||
|           }); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
							
								
								
									
										82
									
								
								node_modules/winston/test/transports/file-maxsize-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								node_modules/winston/test/transports/file-maxsize-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,82 @@ | ||||
| /* | ||||
|  * file-test.js: Tests for instances of the File transport | ||||
|  * | ||||
|  * (C) 2010 Charlie Robbins | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var assert = require('assert'), | ||||
|     exec = require('child_process').exec, | ||||
|     fs = require('fs'), | ||||
|     path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var maxsizeTransport = new winston.transports.File({ | ||||
|   timestamp: false, | ||||
|   json: false, | ||||
|   filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxsize.log'), | ||||
|   maxsize: 4096 | ||||
| }); | ||||
|      | ||||
| vows.describe('winston/transports/file/maxsize').addBatch({ | ||||
|   "An instance of the File Transport": { | ||||
|     "when passed a valid filename": { | ||||
|       "the log() method": { | ||||
|         topic: function () { | ||||
|           exec('rm -rf ' + path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxsize*'), this.callback); | ||||
|         }, | ||||
|         "when passed more than the maxsize": { | ||||
|           topic: function () { | ||||
|             var that = this, | ||||
|                 data = new Array(1018).join('-'); | ||||
|              | ||||
|             // | ||||
|             // Setup a list of files which we will later stat. | ||||
|             // | ||||
|             that.files = []; | ||||
|              | ||||
|             function logKbytes (kbytes) { | ||||
|               // | ||||
|               // With no timestamp and at the info level, | ||||
|               // winston adds exactly 7 characters:  | ||||
|               // [info](4)[ :](2)[\n](1) | ||||
|               // | ||||
|               for (var i = 0; i < kbytes; i++) { | ||||
|                 maxsizeTransport.log('info', data, null, function () { }); | ||||
|               } | ||||
|             } | ||||
|              | ||||
|             maxsizeTransport.on('open', function (file) { | ||||
|               var match = file.match(/(\d+)\.log$/), | ||||
|                   count = match ? match[1] : 0; | ||||
|                | ||||
|               that.files.push(file); | ||||
|                | ||||
|               if (that.files.length === 5) { | ||||
|                 return that.callback(); | ||||
|               } | ||||
|                | ||||
|               logKbytes(4); | ||||
|             }); | ||||
|              | ||||
|             logKbytes(4); | ||||
|           }, | ||||
|           "should create multiple files correctly": function () { | ||||
|             this.files.forEach(function (file) { | ||||
|               try { | ||||
|                 var stats = fs.statSync(file); | ||||
|                 assert.equal(stats.size, 4096); | ||||
|               } | ||||
|               catch (ex) { | ||||
|                 assert.isNull(ex); | ||||
|               } | ||||
|             }); | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
							
								
								
									
										50
									
								
								node_modules/winston/test/transports/file-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								node_modules/winston/test/transports/file-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| /* | ||||
|  * file-test.js: Tests for instances of the File transport | ||||
|  * | ||||
|  * (C) 2010 Charlie Robbins | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     fs = require('fs'), | ||||
|     assert = require('assert'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var stream = fs.createWriteStream(path.join(__dirname, '..', 'fixtures', 'logs', 'testfile.log')), | ||||
|     fileTransport = new (winston.transports.File)({ filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testfilename.log') }), | ||||
|     streamTransport = new (winston.transports.File)({ stream: stream }); | ||||
|  | ||||
| vows.describe('winston/transports/file').addBatch({ | ||||
|   "An instance of the File Transport": { | ||||
|     "when passed a valid filename": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertFile(fileTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(fileTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     }, | ||||
|     "when passed a valid file stream": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertFile(streamTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(streamTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }).addBatch({ | ||||
|   "These tests have a non-deterministic end": { | ||||
|     topic: function () { | ||||
|       setTimeout(this.callback, 200); | ||||
|     }, | ||||
|     "and this should be fixed before releasing": function () { | ||||
|       assert.isTrue(true); | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
							
								
								
									
										61
									
								
								node_modules/winston/test/transports/loggly-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								node_modules/winston/test/transports/loggly-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /* | ||||
|  * loggly-test.js: Tests for instances of the Loggly transport | ||||
|  * | ||||
|  * (C) 2010 Charlie Robbins | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     assert = require('assert'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var config = helpers.loadConfig(); | ||||
|  | ||||
| if (!config) { | ||||
|   return; | ||||
| } | ||||
|  | ||||
| var tokenTransport = new (winston.transports.Loggly)({ | ||||
|       subdomain: config.transports.loggly.subdomain, | ||||
|       inputToken: config.transports.loggly.inputToken | ||||
|     }), | ||||
|     nameTransport = new (winston.transports.Loggly)({  | ||||
|       subdomain: config.transports.loggly.subdomain, | ||||
|       inputName: config.transports.loggly.inputName, | ||||
|       auth: config.transports.loggly.auth | ||||
|     }); | ||||
|  | ||||
| vows.describe('winston/transports/loggly').addBatch({ | ||||
|   "An instance of the Loggly Transport": { | ||||
|     "when passed an input token": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertLoggly(tokenTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(tokenTransport, "should log messages to loggly", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }), | ||||
|       "the log() method with no metadata": { | ||||
|         topic: function () { | ||||
|         tokenTransport.log('info', 'test-message', null, this.callback.bind(null, null)); | ||||
|         }, | ||||
|         "should respond immediately": function () { | ||||
|           assert.isTrue(true); | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     "when passed an input name": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertLoggly(nameTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(nameTransport, "should log messages to loggly", function (ign, err, result) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(result === true || result.response === 'ok'); | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
|  | ||||
							
								
								
									
										119
									
								
								node_modules/winston/test/transports/webhook-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								node_modules/winston/test/transports/webhook-test.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,119 @@ | ||||
| /* | ||||
|  * webhook-test.js: Tests for instances of the Webhook transport | ||||
|  * | ||||
|  * (C) 2011 Marak Squires | ||||
|  * MIT LICENSE | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| var path = require('path'), | ||||
|     vows = require('vows'), | ||||
|     fs = require('fs'), | ||||
|     http = require('http'), | ||||
|     https = require('https'), | ||||
|     assert = require('assert'), | ||||
|     winston = require('../../lib/winston'), | ||||
|     helpers = require('../helpers'); | ||||
|  | ||||
| var webhookTransport = new (winston.transports.Webhook)({  | ||||
|   "host": "localhost", | ||||
|   "port": 8080, | ||||
|   "path": "/winston-test" | ||||
| }); | ||||
|  | ||||
| var httpsWebhookTransport = new (winston.transports.Webhook)({ | ||||
|   "host": "localhost", | ||||
|   "port": 8081, | ||||
|   "path": "/winston-test", | ||||
|   "ssl": true | ||||
| }); | ||||
|  | ||||
| var authWebhookTransport = new (winston.transports.Webhook)({ | ||||
|   "host": "localhost", | ||||
|   "port": 8080, | ||||
|   "path": "/winston-auth-test", | ||||
|   "auth": { | ||||
|     "username": "winston", | ||||
|     "password": "churchill" | ||||
|   } | ||||
| }); | ||||
|  | ||||
| var requestsAuthenticated = true; | ||||
|  | ||||
| var server = http.createServer(function (req, res) { | ||||
|   if (req.url == '/winston-auth-test') { | ||||
|     // | ||||
|     // Test if request has been correctly authenticated | ||||
|     // | ||||
|     // Strip 'Basic' from Authorization header | ||||
|     var signature = req.headers['authorization'].substr(6); | ||||
|     requestsAuthenticated = requestsAuthenticated && | ||||
|       new Buffer(signature, 'base64').toString('utf8') == 'winston:churchill'; | ||||
|   } | ||||
|   res.end(); | ||||
| }); | ||||
|  | ||||
| server.listen(8080); | ||||
|  | ||||
|  | ||||
| var httpsServer = https.createServer({ | ||||
|   cert: fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'keys', 'agent2-cert.pem')), | ||||
|   key: fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'keys', 'agent2-key.pem')) | ||||
| }, function (req, res) { | ||||
|   res.end(); | ||||
| }); | ||||
|  | ||||
| httpsServer.listen(8081); | ||||
|  | ||||
| vows.describe('winston/transports/webhook').addBatch({ | ||||
|   "An instance of the Webhook Transport": { | ||||
|     "when passed valid options": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertWebhook(webhookTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(webhookTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   }, | ||||
|   "An https instance of the Webhook Transport": { | ||||
|     "when passed valid options": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertWebhook(httpsWebhookTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(httpsWebhookTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   }, | ||||
|   "An http Basic Auth instance of the Webhook Transport": { | ||||
|     "when passed valid options": { | ||||
|       "should have the proper methods defined": function () { | ||||
|         helpers.assertWebhook(authWebhookTransport); | ||||
|       }, | ||||
|       "the log() method": helpers.testNpmLevels(authWebhookTransport, "should respond with true", function (ign, err, logged) { | ||||
|         assert.isNull(err); | ||||
|         assert.isTrue(logged); | ||||
|       }) | ||||
|     } | ||||
|   } | ||||
| }).addBatch({ | ||||
|   "When the tests are over": { | ||||
|     topic: function () { | ||||
|       // | ||||
|       // Delay destruction of the server since the  | ||||
|       // WebHook transport responds before the request | ||||
|       // has actually be completed. | ||||
|       // | ||||
|       setTimeout(this.callback, 1000); | ||||
|     }, | ||||
|     "the server should cleanup": function () { | ||||
|       server.close(); | ||||
|     }, | ||||
|     "requests have been correctly authenticated": function () { | ||||
|       assert.ok(requestsAuthenticated); | ||||
|     } | ||||
|   } | ||||
| }).export(module); | ||||
		Reference in New Issue
	
	Block a user