<commit_before>var Step = require('step')
  , request = require('request')
  , config = require('./test-config')
  , models = require('../lib/models')
  , mongoose = require('mongoose')
  , mongodbUrl = process.env.STRIDER_TEST_DB || config.db_uri
  , async = require('async')

console.log("Connecting to MongoDB URL: %s", mongodbUrl);

var TEST_USERS = [
  {email: "<EMAIL>", password: "<PASSWORD>", jar: request.jar()}
, {email: "<EMAIL>", password: "<PASSWORD>", jar: request.jar()}
, {email: "<EMAIL>", password: "password", jar: request.jar()}
];


var importUsers = function(cb){
  console.log("dropping existing users table")
  models.User.remove({}, function(err){
    if (err) throw err;

    console.log("dropped")

    async.eachSeries(TEST_USERS, function(u, done){
      var user = new models.User();
      user.email = u.email
      user.set('password', u.password)

      return user.save(done);
    }, function(err){
      cb(err, null)
    })
  })

}

var importJobs = function(cb){
  console.log("dropping existing jobs table")
  models.Job.remove({}, function(err){
    cb(null)
  })
}

var importProjects = function(cb){
  cb(null)
}

var importSettings = function(cb){
  models.Config.remove({}, function(err){
    if (err) throw err
    new models.Config({version: 1}).save(cb)
  })
}

var dropDB = function(cb){
  console.log("!!!")
  mongoose.connection.db.dropDatabase(function(err){
    console.log("!>")
    if(err) throw err;
    console.log("DB DROPPED")
    cb()
  })
  console.log("!!!!!")
}

var connect = function(cb) {
  mongoose.connect(mongodbUrl, cb);
}

module.exports = function(cb){
  async.series([
      connect
    , dropDB
    , importSettings
    , importUsers
    , importJobs
    , importProjects
    ]
    , function(err, stdout, stderr) {
      if (err) {throw err;}
      cb(null, config)
    })
}

if (!module.parent) {
  module.exports(function(){
    console.log("FIXTURES LOADED")

    process.exit(0)
  })
}<commit_msg>connect doesnt take a callback<commit_after>var Step = require('step')
  , request = require('request')
  , config = require('./test-config')
  , models = require('../lib/models')
  , mongoose = require('mongoose')
  , mongodbUrl = process.env.STRIDER_TEST_DB || config.db_uri
  , async = require('async')

console.log("Connecting to MongoDB URL: %s", mongodbUrl);

var TEST_USERS = [
  {email: "<EMAIL>", password: "<PASSWORD>", jar: request.jar()}
, {email: "<EMAIL>", password: "<PASSWORD>", jar: request.jar()}
, {email: "<EMAIL>", password: "password", jar: request.jar()}
];


var importUsers = function(cb){
  console.log("dropping existing users table")
  models.User.remove({}, function(err){
    if (err) throw err;

    console.log("dropped")

    async.eachSeries(TEST_USERS, function(u, done){
      var user = new models.User();
      user.email = u.email
      user.set('password', u.password)

      return user.save(done);
    }, function(err){
      cb(err, null)
    })
  })

}

var importJobs = function(cb){
  console.log("dropping existing jobs table")
  models.Job.remove({}, function(err){
    cb(null)
  })
}

var importProjects = function(cb){
  cb(null)
}

var importSettings = function(cb){
  models.Config.remove({}, function(err){
    if (err) throw err
    new models.Config({version: 1}).save(cb)
  })
}

var dropDB = function(cb){
  console.log("!!!")
  mongoose.connection.db.dropDatabase(function(err){
    console.log("!>")
    if(err) throw err;
    console.log("DB DROPPED")
    cb()
  })
  console.log("!!!!!")
}

var connect = function(cb) {
  console.log("-->connecting")
  mongoose.connect(mongodbUrl)

  mongoose.connection.on('error',function (err) {
    console.log("ERROR: MONGOOSE CONNNECTION: ", err)
    process.exit(1)
  })

  mongoose.connection.on('disconnected', function (err, res) {
    console.log('Mongoose default connection disconnected', err, res);
  });


  mongoose.connection.on('connected', function (err, res) {
    if(err) throw err
    console.log("<--- connected", err, res)
    cb.apply(this, arguments) 
  });
}

module.exports = function(cb){
  async.series([
      connect
    , dropDB
    , importSettings
    , importUsers
    , importJobs
    , importProjects
    ]
    , function(err, stdout, stderr) {
      if (err) {throw err;}
      cb(null, config)
    })
}

if (!module.parent) {
  module.exports(function(){
    console.log("FIXTURES LOADED")

    process.exit(0)
  })
}
{'fraction_non_alphanumeric': 0.17686921165574881, 'fraction_numerical': 0.00112943302462164, 'mean_word_length': 3.5183673469387755, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, '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': '884597', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1510, 'n_words': 314}