| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/nami/node_modules/winston/test/transports/ |
Upload File : |
/*
* 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);