<commit_before>var spawn = require('child_process').spawn
  , request = require('request');

describe('app', function() {
    var child;

    before(function(done) {
        child = spawn('node', ['app.js']);
        child.stdout.on('data', function(data) {
            setTimeout(done, 50);
        });
        child.stderr.pipe(process.stderr);
    });

    after(function(done) {
        child.on('exit', function() {
            done();
        });
        child.kill();
    });

    it('should have a home page', function(done) {
        request('http://localhost:3000/', function(err, resp, body) {
            resp.statusCode.should.equal(200);
            done();
        });
    });

    it('looks up an id', function(done) {
        request({url:'http://localhost:3000/v0.1/ids',
                 method: 'POST',
                 json: {ids:['http://twitter.com/person']}},
                 function(err, resp, body) {
            resp.statusCode.should.equal(200);
            body.should.have.property('http://twitter.com/person');
            body['http://twitter.com/person'].should.be.empty;
            done();
        });
    });

    it('looks up multiple IDs', function(done) {
        request({url:'http://localhost:3000/v0.1/ids',
                 method: 'POST',
                 json: {ids:['http://twitter.com/person1', 'http://twitter.com/person2']}},
                 function(err, resp, body) {
            resp.statusCode.should.equal(200);
            body.should.have.property('http://twitter.com/person1');
            body.should.have.property('http://twitter.com/person2');
            body['http://twitter.com/person1'].should.be.empty;
            body['http://twitter.com/person2'].should.be.empty;
            done();
        });
    });
});<commit_msg>Use an in-process app instead of spawning a separate app<commit_after>var spawn = require('child_process').spawn
  , server = require('../lib/server')
  , request = require('request');

describe('app', function() {
    var app;

    before(function(done) {

        var config = {
            port: 2342,
            driver: "memory",
            params: {}
        };

        app = server.newServer(config);

        app.run(done);
    });

    after(function(done) {
        done();
    });

    it('should have a home page', function(done) {
        request('http://localhost:2342/', function(err, resp, body) {
            resp.statusCode.should.equal(200);
            done();
        });
    });

    it('looks up an id', function(done) {
        request({url:'http://localhost:2342/v0.1/ids',
                 method: 'POST',
                 json: {ids:['http://twitter.com/person']}},
                 function(err, resp, body) {
            resp.statusCode.should.equal(200);
            body.should.have.property('http://twitter.com/person');
            body['http://twitter.com/person'].should.be.empty;
            done();
        });
    });

    it('looks up multiple IDs', function(done) {
        request({url:'http://localhost:2342/v0.1/ids',
                 method: 'POST',
                 json: {ids:['http://twitter.com/person1', 'http://twitter.com/person2']}},
                 function(err, resp, body) {
            resp.statusCode.should.equal(200);
            body.should.have.property('http://twitter.com/person1');
            body.should.have.property('http://twitter.com/person2');
            body['http://twitter.com/person1'].should.be.empty;
            body['http://twitter.com/person2'].should.be.empty;
            done();
        });
    });
});
{'fraction_non_alphanumeric': 0.18161497625034925, 'fraction_numerical': 0.01899972059234423, 'mean_word_length': 1.9129373474369407, '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': '5476627', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1020, 'n_words': 154}