<commit_before>
module.exports = {
  setUp: function(callback) {
    var Cushion = require('cushion'),
        config = require('./config');

    // block console.log for cushion output
    //this._console = console.log;
    //console.log = function(){};

    console.log(config);
    this.cli = require('../lib/cliRunner');
    this.cli.level = 'connection';
    this.cli.name = config.host;
    this.cli.cushion = new Cushion.Connection(
      config.host, config.port, config.name, config.password
    );

    this.generalCommands = require('../lib/commands/generalCommands');

    this.input = ['does', 'not', 'matter', 'here'];

    callback();
  },

  tearDown: function(callback) {
    //console.log = this._console;

    callback();
  },

  stepBack: {
    connectionLevel: function(test) {
      var cli = this.cli;

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.done();
      };

      this.generalCommands['_..'](this.input, this.cli);
    },

    databaseLevel: function(test) {
      var cli = this.cli;

      cli.level = 'database';
      cli.name = 'testDatabase';
      cli.db = cli.cushion.database('testDatabase');

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.strictEqual(cli.db, undefined);
        test.done();
      };

      this.generalCommands['_..'](this.input, this.cli);
    },

    documentLevel: function(test) {
      var cli = this.cli;

      cli.level = 'document';
      cli.db = cli.cushion.database('testDatabase');
      cli.name = 'testDocument';

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, cli.db.name());
        test.done();
      };

      this.generalCommands['_..'](this.input, this.cli);
    },

    userLevel: function(test) {
      var cli = this.cli;

      cli.user = cli.cushion.user();
      cli.user.name = 'testUser';

      cli.level = 'user';
      cli.name = cli.user.name;

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.done();
      };

      this.generalCommands['_..'](this.input, this.cli);
    },
  },

  connection: function(test) {
    var cli = this.cli;

    cli.level = 'database';
    cli.db = cli.cushion.database('testDatabase');
    cli.name = 'testDatabase';

    this.cli.prompt = function() {
      test.strictEqual(cli.level, 'connection');
      test.strictEqual(cli.name, cli.cushion.option('host'));
      test.strictEqual(cli.db, undefined);
      test.done();
    };

    this.generalCommands._connection(this.input, this.cli);
  },

  database: {
    databaseUp: function(test) {
      var cli = this.cli,
          input = ['database', 'testDatabase'];

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, 'testDatabase');
        test.ok(cli.db);
        test.strictEqual(cli.db.name(), 'testDatabase');
        test.done();
      };

      this.generalCommands._database(input, this.cli);
    },

    databaseDown: function(test) {
      var cli = this.cli,
          input = ['database'];

      cli.level = 'document';
      cli.db = cli.cushion.database('testDatabase');
      cli.name = 'testDocument';

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, 'testDatabase');
        test.done();
      };

      this.generalCommands._database(input, this.cli);
    }
  },

  listDatabases: function(test) {
    var cli = this.cli,
        input = ['listDatabases'];

    this.cli.connectionCallbacks.listDatabases = function(error, databases) {
      console.log(error);

      test.ok(!error);
      test.ok(databases);
      test.ok(databases instanceof Array);
      test.done();
    };

    this.generalCommands._listDatabases(input, this.cli);
  },

  user: function(test) {
    var cli = this.cli,
        input = ['user', 'stefan'];

    this.cli.prompt = function() {
      test.strictEqual(cli.level, 'user');
      test.strictEqual(cli.name, 'stefan');
      test.ok(cli.user);
      test.strictEqual(cli.user.name, 'stefan');
      test.done();
    };

    this.generalCommands._user(input, this.cli);
  }
};
<commit_msg>travis debugging + refactoring<commit_after>
module.exports = {
  setUp: function(callback) {
    var Cushion = require('cushion'),
        config = require('./config');

    // block console.log for cushion output
    //this._console = console.log;
    //console.log = function(){};

    console.log(config);
    this.cli = require('../lib/cliRunner');
    this.cli.level = 'connection';
    this.cli.name = config.host;
    this.cli.cushion = new Cushion.Connection(
      config.host, config.port, config.name, config.password
    );

    this.cli.generalCommands = require('../lib/commands/generalCommands');

    this.input = ['does', 'not', 'matter', 'here'];

    callback();
  },

  tearDown: function(callback) {
    //console.log = this._console;

    callback();
  },

  stepBack: {
    connectionLevel: function(test) {
      var cli = this.cli;

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.done();
      };

      this.cli.generalCommands['_..'](this.input, this.cli);
    },

    databaseLevel: function(test) {
      var cli = this.cli;

      cli.level = 'database';
      cli.name = 'testDatabase';
      cli.db = cli.cushion.database('testDatabase');

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.strictEqual(cli.db, undefined);
        test.done();
      };

      this.cli.generalCommands['_..'](this.input, this.cli);
    },

    documentLevel: function(test) {
      var cli = this.cli;

      cli.level = 'document';
      cli.db = cli.cushion.database('testDatabase');
      cli.name = 'testDocument';

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, cli.db.name());
        test.done();
      };

      this.cli.generalCommands['_..'](this.input, this.cli);
    },

    userLevel: function(test) {
      var cli = this.cli;

      cli.user = cli.cushion.user();
      cli.user.name = 'testUser';

      cli.level = 'user';
      cli.name = cli.user.name;

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'connection');
        test.strictEqual(cli.name, '127.0.0.1');
        test.done();
      };

      this.cli.generalCommands['_..'](this.input, this.cli);
    },
  },

  connection: function(test) {
    var cli = this.cli;

    cli.level = 'database';
    cli.db = cli.cushion.database('testDatabase');
    cli.name = 'testDatabase';

    this.cli.prompt = function() {
      test.strictEqual(cli.level, 'connection');
      test.strictEqual(cli.name, cli.cushion.option('host'));
      test.strictEqual(cli.db, undefined);
      test.done();
    };

    this.cli.generalCommands._connection(this.input, this.cli);
  },

  database: {
    databaseUp: function(test) {
      var cli = this.cli;

      this.input = ['database', 'testDatabase'];

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, 'testDatabase');
        test.ok(cli.db);
        test.strictEqual(cli.db.name(), 'testDatabase');
        test.done();
      };

      this.cli.generalCommands._database(this.input, this.cli);
    },

    databaseDown: function(test) {
      var cli = this.cli;

      this.input = ['database'];

      cli.level = 'document';
      cli.db = cli.cushion.database('testDatabase');
      cli.name = 'testDocument';

      this.cli.prompt = function() {
        test.strictEqual(cli.level, 'database');
        test.strictEqual(cli.name, 'testDatabase');
        test.done();
      };

      this.cli.generalCommands._database(this.input, this.cli);
    }
  },

  listDatabases: function(test) {
    var cli = this.cli;

    this.input = ['listDatabases'];

    this.cli.connectionCallbacks.listDatabases = function(error, databases) {
      console.log(error);

      test.ok(!error);
      test.ok(databases);
      test.ok(databases instanceof Array);
      test.done();
    };

    this.cli.generalCommands._listDatabases(this.input, this.cli);
  },

  user: function(test) {
    var cli = this.cli;

    this.input = ['user', 'stefan'];

    this.cli.prompt = function() {
      test.strictEqual(cli.level, 'user');
      test.strictEqual(cli.name, 'stefan');
      test.ok(cli.user);
      test.strictEqual(cli.user.name, 'stefan');
      test.done();
    };

    this.cli.generalCommands._user(this.input, this.cli);
  }
};

{'fraction_non_alphanumeric': 0.1686518980296115, 'fraction_numerical': 0.004007569854168985, 'mean_word_length': 2.458044649730562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '7560410', 'n_tokens_mistral': 3016, 'n_tokens_neox': 2887, 'n_words': 458}