<commit_before>var utils = require('./test-utils');

var assert = require('chai').assert;

var Domain = require('../lib/database/domain').Domain;

suite('database', function() {
  suite('Domain', function() {
    test('initial status', function() {
      var domain = new Domain('newdomain');
      assert.deepEqual({
        searchableDocumentsCount: domain.searchableDocumentsCount,
        requiresIndexDocuments:   domain.requiresIndexDocuments,
        searchInstanceCount:      domain.searchInstanceCount,
        searchPartitionCount:     domain.searchPartitionCount
      }, {
        searchableDocumentsCount: 0,
        requiresIndexDocuments:   false,
        searchInstanceCount:      0,
        searchPartitionCount:     0
      });
    });

    test('lower case', function() {
      var domain = new Domain('valid');
      domain.id = Domain.DEFAULT_ID;
      assert.equal(domain.tableName,
                   'valid_' + Domain.DEFAULT_ID);
    });

    test('lower case and number', function() {
      var domain = new Domain('valid123');
      domain.id = Domain.DEFAULT_ID;
      assert.equal(domain.tableName,
                   'valid123_' + Domain.DEFAULT_ID);
    });

    test('without name', function() {
      assert.throw(function() {
        var domain = new Domain('');
      }, '2 validation errors detected: ' +
           'Value \'\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+; ' +
           'Value \'\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too short (1 character)', function() {
      assert.throw(function() {
        var domain = new Domain('v');
      }, '2 validation errors detected: ' +
           'Value \'v\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+; ' +
           'Value \'v\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too short (2 characters)', function() {
      assert.throw(function() {
        var domain = new Domain('va');
      }, '1 validation error detected: ' +
           'Value \'va\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too long', function() {
      assert.throw(function() {
        var domain = new Domain('abcdefghijklmnopqrstuvwxyz' +
                                '0123456789');
      }, /too long domain name/);
    });

    test('hyphen', function() {
      assert.throw(function() {
        try {
        var domain = new Domain('domain-name');
        } catch(e) { console.log(e); }
      }, '1 validation error detected: ' +
           'Value \'domain_name\' at \'domainName\' failed to satisfy constraint: ' +
             'Member cannot include these characters: \'-\'');
    });

    test('underscore', function() {
      assert.throw(function() {
        var domain = new Domain('domain_name');
      }, '1 validation error detected: ' +
           'Value \'domain_name\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+');
    });

    test('upper case', function() {
      assert.throw(function() {
        var domain = new Domain('DomainName');<commit_msg>Update test for actual error<commit_after>var utils = require('./test-utils');

var assert = require('chai').assert;

var Domain = require('../lib/database/domain').Domain;

suite('database', function() {
  suite('Domain', function() {
    test('initial status', function() {
      var domain = new Domain('newdomain');
      assert.deepEqual({
        searchableDocumentsCount: domain.searchableDocumentsCount,
        requiresIndexDocuments:   domain.requiresIndexDocuments,
        searchInstanceCount:      domain.searchInstanceCount,
        searchPartitionCount:     domain.searchPartitionCount
      }, {
        searchableDocumentsCount: 0,
        requiresIndexDocuments:   false,
        searchInstanceCount:      0,
        searchPartitionCount:     0
      });
    });

    test('lower case', function() {
      var domain = new Domain('valid');
      domain.id = Domain.DEFAULT_ID;
      assert.equal(domain.tableName,
                   'valid_' + Domain.DEFAULT_ID);
    });

    test('lower case and number', function() {
      var domain = new Domain('valid123');
      domain.id = Domain.DEFAULT_ID;
      assert.equal(domain.tableName,
                   'valid123_' + Domain.DEFAULT_ID);
    });

    test('without name', function() {
      assert.throw(function() {
        var domain = new Domain('');
      }, '2 validation errors detected: ' +
           'Value \'\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+; ' +
           'Value \'\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too short (1 character)', function() {
      assert.throw(function() {
        var domain = new Domain('v');
      }, '2 validation errors detected: ' +
           'Value \'v\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+; ' +
           'Value \'v\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too short (2 characters)', function() {
      assert.throw(function() {
        var domain = new Domain('va');
      }, '1 validation error detected: ' +
           'Value \'va\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length greater than or equal to 3');
    });

    test('too long', function() {
      var name = 'abcdefghijklmnopqrstuvwxyz0123456789';
      assert.throw(function() {
        var domain = new Domain(name);
      }, '1 validation error detected: ' +
           'Value \'' + name + '\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must have length smaller than or equal to 28');
    });

    test('hyphen', function() {
      assert.throw(function() {
        try {
        var domain = new Domain('domain-name');
        } catch(e) { console.log(e); }
      }, '1 validation error detected: ' +
           'Value \'domain_name\' at \'domainName\' failed to satisfy constraint: ' +
             'Member cannot include these characters: \'-\'');
    });

    test('underscore', function() {
      assert.throw(function() {
        var domain = new Domain('domain_name');
      }, '1 validation error detected: ' +
           'Value \'domain_name\' at \'domainName\' failed to satisfy constraint: ' +
             'Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+');
    });

    test('upper case', function() {
      assert.throw(function() {
        var domain = new Domain('DomainName');
{'fraction_non_alphanumeric': 0.14235820061469684, 'fraction_numerical': 0.010198379435596535, 'mean_word_length': 2.334420121099208, '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': '2462207', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1874, 'n_words': 543}