<commit_before>/*jshint expr: true*/

var request = require('request');
var FormData = require('form-data');
var expect = require('chai').expect;
var spawn = require('child_process').spawn;

var PORT = 3000;
var bowerServerUrl = 'http://localhost:' + PORT;

describe('registry server', function(){
    var server = null;

    before(function(done){
        // Ensure time for integration tests
        this.timeout(5000);
        process.env.PORT = PORT;
        server = spawn('node', ['index.js']);
        server.stdout.on('data', function(data){
            if (data.toString() === 'ready.\n') {                
                done();
            }
        });
    });

    after(function(){
        server.kill();
    });

    describe('headers', function() {
        it('should support CORS', function (done) {
            request.get(bowerServerUrl + '/status', function (err, res, body){
                expect(res.headers['access-control-allow-origin']).not.to.be.null;
                done();
            });
        });
    });

    describe('routes', function() {
        describe('/status', function() {
            it('should return 200 when server is running', function (done) {
                request.get(bowerServerUrl + '/status', function (err, res, body){
                    expect(res.statusCode).to.equal(200);
                    done();
                });
            });
        });

        describe('/packages', function() {
            it('should return 500/database error before psql is setup', function (done) {
                request.get(bowerServerUrl + '/packages', function (err, res, body){
                    expect(res.statusCode).to.equal(500);
                    done();
                });<commit_msg>Skip test relying on race condition<commit_after>/*jshint expr: true*/

var request = require('request');
var FormData = require('form-data');
var expect = require('chai').expect;
var spawn = require('child_process').spawn;

var PORT = 3000;
var bowerServerUrl = 'http://localhost:' + PORT;

describe('registry server', function(){
    var server = null;

    before(function(done){
        // Ensure time for integration tests
        this.timeout(5000);
        process.env.PORT = PORT;
        server = spawn('node', ['index.js']);
        server.stdout.on('data', function(data){
            if (data.toString() === 'ready.\n') {                
                done();
            }
        });
    });

    after(function(){
        server.kill();
    });

    describe('headers', function() {
        it('should support CORS', function (done) {
            request.get(bowerServerUrl + '/status', function (err, res, body){
                expect(res.headers['access-control-allow-origin']).not.to.be.null;
                done();
            });
        });
    });

    describe('routes', function() {
        describe('/status', function() {
            it('should return 200 when server is running', function (done) {
                request.get(bowerServerUrl + '/status', function (err, res, body){
                    expect(res.statusCode).to.equal(200);
                    done();
                });
            });
        });

        describe('/packages', function() {
            // This test relied on race condition and failed on CI
            it.skip('should return 500/database error before psql is setup', function (done) {
                request.get(bowerServerUrl + '/packages', function (err, res, body){
                    expect(res.statusCode).to.equal(500);
                    done();
                });
{'fraction_non_alphanumeric': 0.152924791086351, 'fraction_numerical': 0.011142061281337047, 'mean_word_length': 1.8820224719101124, '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': '2929227', 'n_tokens_mistral': 982, 'n_tokens_neox': 914, 'n_words': 223}