<commit_before>var test = require('../test');
var RedisCheckpoint = require(process.cwd() + '/services/redis-checkpoint');

describe('RedisCheckpoint',function() {

    beforeEach(function () {
        test.mockery.enable();
        test.mockery.registerMock('then-redis', test.mockredis);
        test.mockery.warnOnUnregistered(false);
        test.mockredis.reset();
    });

    afterEach(function () {
        test.mockery.deregisterMock('then-redis');
        test.mockery.disable();
        test.mockredis.snapshot().should.eql([]);
        test.pp.snapshot().should.eql([]);
    });

    it('should properly initialize data with minimal arguments',function(){
        var checkpoint = new RedisCheckpoint();
        checkpoint.config.should.eql({retryInterval: 5000});
        test.pp.snapshot().should.eql([]);
        test.mockredis.snapshot().should.eql([]);
    });

    it('should properly initialize data with all arguments',function(){
        var checkpoint = new RedisCheckpoint({retryInterval: 1000,extra: 1});
        checkpoint.config.should.eql({retryInterval: 1000,extra: 1});
        test.pp.snapshot().should.eql([]);
        test.mockredis.snapshot().should.eql([]);
    });

    it('should retry if redis client throws an error',function(done){
        test.mockredis.clientException = 'test error';

        var count = 0;
        var checkpoint = new RedisCheckpoint({retryInterval: 10});
        checkpoint.start(function(event){
            event.should.eql('retry');
            if (count++ > 0) {
                checkpoint.stop();
                test.pp.snapshot().should.eql([
                    '[redis-chk ] start checkpoint',
                    '[redis-chk ] redis client error: test error',
                    '[redis-chk ] redis client error: test error',
                    '[redis-chk ] stop checkpoint'
                ]);
                test.mockredis.snapshot().should.eql([
                    {end: null},
                    {end: null}<commit_msg>end() method not included in then-redis - fix tests<commit_after>var test = require('../test');
var RedisCheckpoint = require(process.cwd() + '/services/redis-checkpoint');

describe('RedisCheckpoint',function() {

    beforeEach(function () {
        test.mockery.enable();
        test.mockery.registerMock('then-redis', test.mockredis);
        test.mockery.warnOnUnregistered(false);
        test.mockredis.reset();
    });

    afterEach(function () {
        test.mockery.deregisterMock('then-redis');
        test.mockery.disable();
        test.mockredis.snapshot().should.eql([]);
        test.pp.snapshot().should.eql([]);
    });

    it('should properly initialize data with minimal arguments',function(){
        var checkpoint = new RedisCheckpoint();
        checkpoint.config.should.eql({retryInterval: 5000});
        test.pp.snapshot().should.eql([]);
        test.mockredis.snapshot().should.eql([]);
    });

    it('should properly initialize data with all arguments',function(){
        var checkpoint = new RedisCheckpoint({retryInterval: 1000,extra: 1});
        checkpoint.config.should.eql({retryInterval: 1000,extra: 1});
        test.pp.snapshot().should.eql([]);
        test.mockredis.snapshot().should.eql([]);
    });

    it('should retry if redis client throws an error',function(done){
        test.mockredis.clientException = 'test error';

        var count = 0;
        var checkpoint = new RedisCheckpoint({retryInterval: 10});
        checkpoint.start(function(event){
            event.should.eql('retry');
            if (count++ > 0) {
                checkpoint.stop();
                test.pp.snapshot().should.eql([
                    '[redis-chk ] start checkpoint',
                    '[redis-chk ] redis client error: test error',
                    '[redis-chk ] redis client error: test error',
                    '[redis-chk ] stop checkpoint'
                ]);
                test.mockredis.snapshot().should.eql([
                    {quit: null},
                    {quit: null}
{'fraction_non_alphanumeric': 0.14844136566056407, 'fraction_numerical': 0.008906481939633844, 'mean_word_length': 2.3112203112203114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1554540', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1133, 'n_words': 208}