<commit_before>var given = require('./builder.js').given;
var config = require('../config.js');
var expect = require('chai').expect;

describe('config', function() {
    it('returns an error if config file not found', function(done) {
        config.load('./filenotfound.json')
        .fail(function(error) {
            expect(error).to.exist();
            done();
        })
        .done();
    });

    it('returns an error if no config file specified', function(done) {
        config.load()
        .fail(function(error) {
            expect(error).to.contain('specify a config file');
            done();
        })
        .done();
    });

    it('reads all urls from file', function(done) {
        given().aConfigFile()
            .withUrl('http://localhost:55557/one')
            .withUrl('http://localhost:55557/two')
            .withUrl('http://localhost:55557/three')
        .then(function(configFilename) {
            return config.load(configFilename).then(function(loaded) {
                expect(loaded.urls.length).to.equal(3);
            });
        }).then(done).done();;
    });

    it('parses environment variables', function(done) {
        var certPath = '/path/to/cert.pem';
        process.env['CLIENT_CERT'] = certPath;

        given().aConfigFile()
            .withClientCert('$CLIENT_CERT')
        .then(function(configFilename) {
            return config.load(configFilename).then(function(loaded) {
                expect(loaded.client.cert).to.equal(certPath);
            });
        }).then(done).done();
    });
});<commit_msg>Use generic test URLs in config tests<commit_after>var given = require('./builder.js').given;
var config = require('../config.js');
var expect = require('chai').expect;

describe('config', function() {
    it('returns an error if config file not found', function(done) {
        config.load('./filenotfound.json')
        .fail(function(error) {
            expect(error).to.exist();
            done();
        })
        .done();
    });

    it('returns an error if no config file specified', function(done) {
        config.load()
        .fail(function(error) {
            expect(error).to.contain('specify a config file');
            done();
        })
        .done();
    });

    it('reads all urls from file', function(done) {
        given().aConfigFile()
            .withUrl('http://test.example.com/one')
            .withUrl('http://test.example.com/two')
            .withUrl('http://test.example.com/three')
        .then(function(configFilename) {
            return config.load(configFilename).then(function(loaded) {
                expect(loaded.urls.length).to.equal(3);
            });
        }).then(done).done();;
    });

    it('parses environment variables', function(done) {
        var certPath = '/path/to/cert.pem';
        process.env['CLIENT_CERT'] = certPath;

        given().aConfigFile()
            .withClientCert('$CLIENT_CERT')
        .then(function(configFilename) {
            return config.load(configFilename).then(function(loaded) {
                expect(loaded.client.cert).to.equal(certPath);
            });
        }).then(done).done();
    });
});
{'fraction_non_alphanumeric': 0.1674520892240025, 'fraction_numerical': 0.0053408733898837575, 'mean_word_length': 2.155599603567889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7349493', 'n_tokens_mistral': 916, 'n_tokens_neox': 893, 'n_words': 152}