<commit_before>'use strict';

var fs = require('fs'),
  f = require('util').format;

/**
 * @ignore
 */
exports['Should run all connection string tests'] = {
  metadata: { requires: { topology: 'single' } },

  // The actual test we wish to run
  test: function(configuration, assert) {
    var testFiles = fs
      .readdirSync(f('%s/connection-string', __dirname))
      .filter(function(x) {
        return x.indexOf('.json') != -1;
      })
      .map(function(x) {
        return JSON.parse(fs.readFileSync(f('%s/connection-string/%s', __dirname, x)));
      });

    var parser = require('../../lib/url_parser');

    // Execute the tests
    for (var i = 0; i < testFiles.length; i++) {
      var testFile = testFiles[i];

      // Get each test
      for (var j = 0; j < testFile.tests.length; j++) {
        var test = testFile.tests[j];
        console.log(f('  %s', test.description));
        // console.dir(test)

        // Unpack the test
        var auth = test.auth;
        var description = test.description;
        var hosts = test.hosts;
        var options = test.options;
        var uri = test.uri;
        var valid = test.valid;
        var warning = test.warning;

        // Test state
        var success = true;

        // Parse the test
        try {
          var result = parser(test.uri);
          if (valid == false) success = false;
        } catch (err) {
          // console.log(err.stack)
          if (valid == true) success = false;
        }

        // If we were unsuccessful
        if (!success) {
          throw test;
        }
      }
    }

    assert.done();
  }
};<commit_msg>test(connection-string): convert `connection_string` tests to mocha<commit_after>'use strict';

var parse = require('../../lib/url_parser');
var fs = require('fs'),
  f = require('util').format;

describe('Connection String', function() {
  var testFiles = fs
    .readdirSync(f('%s/connection-string', __dirname))
    .filter(function(x) {
      return x.indexOf('.json') != -1;
    })
    .map(function(x) {
      return JSON.parse(fs.readFileSync(f('%s/connection-string/%s', __dirname, x)));
    });

  // Execute the tests
  for (var i = 0; i < testFiles.length; i++) {
    var testFile = testFiles[i];

    // Get each test
    for (var j = 0; j < testFile.tests.length; j++) {
      var test = testFile.tests[j];

      it(test.description, {
        metadata: { requires: { topology: 'single' } },
        test: function(done) {
          var valid = test.valid;

          try {
            parse(test.uri);
            if (valid == false) done('should not have been able to parse');
          } catch (err) {
            if (valid == true) done(err);
          }

          done();
        }
      });
    }
  }
});
{'fraction_non_alphanumeric': 0.15778019586507072, 'fraction_numerical': 0.002176278563656148, 'mean_word_length': 1.968783638320775, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2266678', 'n_tokens_mistral': 859, 'n_tokens_neox': 835, 'n_words': 220}