<commit_before>var assert = require('chai').assert;
var PgBoss = require('../lib/index');
var config = require('./config.json');
var helper = require('./testService');

describe('delayed jobs', function(){
    it('should wait before processing a delayed job submission', function(finished) {

        // todo: temp test for travis config override
        if(process.env.TRAVIS) {
            config.port = 5433;
            config.password = '';
        }

        var boss = new PgBoss(config);
        boss.start();

        boss.on('error', error => console.error(error));
        boss.on('ready', () => helper.init().then(ready));

        function ready() {

            var delaySeconds = 1;

            boss.subscribe('wait', null, (job, done) => {
                var start = new Date(job.data.submitted);
                var end = new Date();

                var elapsedSeconds = Math.floor((end-start)/1000);

                console.log(`job ${job.id} received in ${elapsedSeconds} seconds with payload: ${job.data.message}`);

                done().then(() => {
                    assert.isAtLeast(delaySeconds, elapsedSeconds);
                    finished();
                });
            });

            boss.publish('wait', {message: 'hold your horses', submitted: Date.now()}, {startIn: delaySeconds})
                .then(jobId => {
                    console.log(`job id ${jobId} requested to start in ${delaySeconds} seconds`);
                });

        }

    });
});



<commit_msg>increased timeout for delayed job test<commit_after>var assert = require('chai').assert;
var PgBoss = require('../lib/index');
var config = require('./config.json');
var helper = require('./testService');

describe('delayed jobs', function(){
    it('should wait before processing a delayed job submission', function(finished) {

        var delaySeconds = 2;
        this.timeout(3000);

        // todo: temp test for travis config override
        if(process.env.TRAVIS) {
            config.port = 5433;
            config.password = '';
        }

        var boss = new PgBoss(config);
        boss.start();

        boss.on('error', error => console.error(error));
        boss.on('ready', () => helper.init().then(ready));

        function ready() {
            boss.subscribe('wait', null, (job, done) => {
                var start = new Date(job.data.submitted);
                var end = new Date();

                var elapsedSeconds = Math.floor((end-start)/1000);

                console.log(`job ${job.id} received in ${elapsedSeconds} seconds with payload: ${job.data.message}`);

                done().then(() => {
                    assert.isAtLeast(delaySeconds, elapsedSeconds);
                    finished();
                });
            });

            boss.publish('wait', {message: 'hold your horses', submitted: Date.now()}, {startIn: delaySeconds})
                .then(jobId => {
                    console.log(`job id ${jobId} requested to start in ${delaySeconds} seconds`);
                });

        }

    });
});




{'fraction_non_alphanumeric': 0.15064935064935064, 'fraction_numerical': 0.007142857142857143, 'mean_word_length': 1.9148533585619678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, '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': '7212072', 'n_tokens_mistral': 856, 'n_tokens_neox': 795, 'n_words': 200}