<commit_before>'use strict'

const expect = require('code').expect
const Lab = require('lab');
const lab = exports.lab = Lab.script();
const pino = require('../../pino-eventhub')
var pump = require('pump')
var fs = require('fs')

lab.experiment('Pino Event Hub', () => {
    let opts;
    let source
    let now
    let week
    let ehn
    let eh
    let sapn
    let sapk
    let sas
    let se
    let host
    let uri

        lab.beforeEach((done) => {
            opts = {};
            source = fs.createReadStream('/dev/random')
            source.setEncoding('utf8');
            now = new Date()
            week = 60*60*24*7
            ehn = opts['event-hub-namespace'] || process.env.PINO_EVENT_HUB_NAMESPACE
            eh = opts['event-hub'] || process.env.PINO_EVENT_HUB
            sapn = opts['shared-access-policy-name'] || process.env.PINO_SHARED_ACCESS_POLICY_NAME
            sapk = opts['shared-access-policy-key'] || process.env.PINO_SHARED_ACCESS_POLICY_KEY
            sas = opts['sas'] || process.env.PINO_SHARED_ACCESS_SIGNATURE
            se = opts.expiry || process.env.PINO_SAS_EXPIRY
            || Math.round(now.getTime() / 1000) + week
            host = 'https://' + ehn + '.servicebus.windows.net'
            uri = encodeURIComponent(host + '/' + eh)
            done();
        });
        lab.test('returns done', (done) => {
            const sig = pino.createSignature(uri, se, sapk, true);
            console.log(sig)
            done();
        });

        lab.test('returns done', (done) => {
            const options = Object.assign(opts, {
                host,
                eh,
                sr: uri,
                sig: pino.createSignature(uri, se, sapk, false),
                se,
                skn: sapn,
        })
            pump(source, pino.pinoEventHub(options),function(err) {
                expect(err).to.exist()
                expect(err.message).to.contain("premature close")
                done();
            })

            setTimeout(function () {
                source.destroy()
            }, 1000)

        });

        lab.test('returns done', (done) => {

            const options = Object.assign(opts, {
                host,
                eh,
                sr: uri,
                sig: "no signature",
                se,
                skn: sapn,
            })
            pump(source, pino.pinoEventHub(options),function(err) {
                expect(err).to.exist()
                expect(err.message).to.equal("401")
                done();
            })
            setTimeout(function () {
                source.destroy()
            }, 1000)
        });
});<commit_msg>fixed test<commit_after>'use strict'

const expect = require('code').expect
const Lab = require('lab');
const lab = exports.lab = Lab.script();
const pino = require('../../pino-eventhub')
var pump = require('pump')
var fs = require('fs')

lab.experiment('Pino Event Hub', () => {
    let opts;
    let source
    let now
    let week
    let ehn
    let eh
    let sapn
    let sapk
    let sas
    let se
    let host
    let uri

        lab.beforeEach((done) => {
            opts = {};
            source = fs.createReadStream('/dev/random')
            source.setEncoding('utf8');
            now = new Date()
            week = 60*60*24*7
            ehn = opts['event-hub-namespace'] || process.env.PINO_EVENT_HUB_NAMESPACE
            eh = opts['event-hub'] || process.env.PINO_EVENT_HUB
            sapn = opts['shared-access-policy-name'] || process.env.PINO_SHARED_ACCESS_POLICY_NAME
            sapk = opts['shared-access-policy-key'] || process.env.PINO_SHARED_ACCESS_POLICY_KEY
            sas = opts['sas'] || process.env.PINO_SHARED_ACCESS_SIGNATURE
            se = opts.expiry || process.env.PINO_SAS_EXPIRY
            || Math.round(now.getTime() / 1000) + week
            host = 'https://' + ehn + '.servicebus.windows.net'
            uri = encodeURIComponent(host + '/' + eh)
            done();
        });
        lab.test('returns done', (done) => {
            const sig = pino.createSignature(uri, se, sapk, true);
            expect(sig).to.exist()
            done();
        });

        lab.test('returns done', (done) => {
            const options = Object.assign(opts, {
                host,
                eh,
                sr: uri,
                sig: pino.createSignature(uri, se, sapk, false),
                se,
                skn: sapn,
        })
            pump(source, pino.pinoEventHub(options),function(err) {
                expect(err).to.exist()
                expect(err.message).to.contain("premature close")
                done();
            })

            setTimeout(function () {
                source.destroy()
            }, 1000)

        });

        lab.test('returns done', (done) => {

            const options = Object.assign(opts, {
                host,
                eh,
                sr: uri,
                sig: "no signature",
                se,
                skn: sapn,
            })
            pump(source, pino.pinoEventHub(options),function(err) {
                expect(err).to.exist()
                expect(err.message).to.equal("401")
                done();
            })
            setTimeout(function () {
                source.destroy()
            }, 1000)
        });
});
{'fraction_non_alphanumeric': 0.13496359902930744, 'fraction_numerical': 0.008586895650550682, 'mean_word_length': 1.477115117891817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5793272', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1543, 'n_words': 299}