diff options
author | Minteck <contact@minteck.org> | 2021-12-21 16:50:49 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-21 16:50:49 +0100 |
commit | 20204baf1807825af4798ad03bfb329e4da05bc5 (patch) | |
tree | 1568515fa1e4592206ed5d2327b39e6b443cbd03 /node_modules/winston/test/transports/http-test.js | |
download | bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.tar.gz bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.tar.bz2 bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.zip |
Commit
Diffstat (limited to 'node_modules/winston/test/transports/http-test.js')
-rw-r--r-- | node_modules/winston/test/transports/http-test.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/node_modules/winston/test/transports/http-test.js b/node_modules/winston/test/transports/http-test.js new file mode 100644 index 0000000..65f3cc7 --- /dev/null +++ b/node_modules/winston/test/transports/http-test.js @@ -0,0 +1,70 @@ +/* + * http-test.js: Tests for instances of the HTTP transport + * + * MIT LICENSE + */ + +var path = require('path'), + vows = require('vows'), + http = require('http'), + fs = require('fs'), + assert = require('assert'), + winston = require('../../lib/winston'), + helpers = require('../helpers'), + hock = require('hock'); + +var transport = require('./transport'); + +var host = '127.0.0.1'; + +vows.describe('winston/transports/http').addBatch({ + "When the HTTP endpoint": { + topic: function () { + var mock = this.mock = hock.createHock(), + self = this; + + mock + .post('/log', { + "method":"collect", + "params":{ + "level":"info", + "message":"hello", + "meta":{} + } + }) + .min(1) + .max(1) + .reply(200); + + var server = this.server = http.createServer(mock.handler); + server.listen(0, '0.0.0.0', this.callback); + }, + "is running": function (err) { + assert.ifError(err); + }, + "an instance of the Http transport": { + topic: function () { + + var port = this.server.address().port; + var self = this, + httpTransport = new (winston.transports.Http)({ + host: host, + port: port, + path: 'log' + }); + + httpTransport.log('info', 'hello', function (logErr, logged) { + self.mock.done(function (doneErr) { + self.callback(null, logErr, logged, doneErr); + }); + }); + }, + "should log to the specified URL": function (_, err, logged, requested) { + assert.ifError(err); + assert.isTrue(logged); + assert.ifError(requested); + this.server.close(); + } + } + } +}).export(module); |