Skip to content

Commit

Permalink
enh
Browse files Browse the repository at this point in the history
  • Loading branch information
davidedantonio committed Jan 24, 2019
1 parent 225f083 commit d6a21b1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pino = require('pino')
const proxyquire = require('proxyquire')
const test = require('tap').test
const fix = require('./fixtures')
const fluentd = require('fluent-logger')

const matchISOString = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/
const options = {
Expand All @@ -25,16 +26,26 @@ test('make sure log is a valid json', (t) => {
t.equal(tagPrefix, `${options.tag}`)
t.equal(config.host, `${options.host}`)

return {
emit: function (key, data, cb) {
let client = fluentd.createFluentSender(tagPrefix, {
host: config.host ? config.host : undefined,
port: config.port ? config.port : undefined,
timeout: config.timeout ? config.timeout : undefined,
reconnectInterval: config['reconnect-interval'] ? config['reconnect-interval'] : undefined,
flushInterval: config['flush-interval'] ? config['flush-interval'] : undefined
})

client = Object.assign(client, {
emit: (key, data, cb) => {
t.type(key, 'string')
t.ok(data, true)
t.type(data.time, 'string')
t.match(data.time, matchISOString)
cb(null, {})
t.end()
}
}
})

return client
}

const fluent = proxyquire('../', {
Expand Down

0 comments on commit d6a21b1

Please sign in to comment.