<commit_before>var assert = require('chai').assert;

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

var builders = require('../lib/adapter/api/rest-request-builder');

suite('building message from REST adapter request', function() {
  suite('search', function() {
    test('simple query', function() {
      var fakeRequest = {
        params: {
          tableName: 'test_table'
        },
        query: {
          query: 'foobar'
        }
      };
      var expectedBody = {
        queries: {
          result: {
            source: 'test_table',
            condition: {
              query:  'foobar'
            },
            output: {
              elements: utils.allElements,
              attributes: []
            }
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    test('with options', function() {
      var fakeRequest = {
        params: {
          tableName: 'people'
        },
        query: {
          query:      'foobar',
          offset:     '10',
          limit:      '100',
          match_to:   'realname,nickname',
          sort_by:    '-realname,-nickname',
          attributes: 'realname,nickname,age,job',
          timeout:    '1000'
        }
      };
      var expectedBody = {
        timeout: 1000,
        queries: {
          result: {
            source:  'people',
            condition: {
              query:   'foobar',
              matchTo: ['realname', 'nickname'],
            },
            offset:  10,
            sortBy:  ['-realname', '-nickname'],
            output: {
              attributes: ['realname', 'nickname', 'age', 'job'],
              elements: utils.allElements,
              limit:   100,
            }
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    suite('validation', function() {
      function deepClone(base) {<commit_msg>Update expected queries built by the query builder<commit_after>var assert = require('chai').assert;

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

var builders = require('../lib/adapter/api/rest-request-builder');

suite('building message from REST adapter request', function() {
  suite('search', function() {
    test('simple query', function() {
      var fakeRequest = {
        params: {
          tableName: 'test_table'
        },
        query: {
          query: 'foobar'
        }
      };
      var expectedBody = {
        queries: {
          'test-tables': {
            source: 'test_table',
            condition: {
              query:  'foobar'
            },
            output: {
              elements: utils.allElements,
              attributes: []
            }
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    test('with options', function() {
      var fakeRequest = {
        params: {
          tableName: 'people'
        },
        query: {
          query:      'foobar',
          offset:     '10',
          limit:      '100',
          match_to:   'realname,nickname',
          sort_by:    '-realname,-nickname',
          attributes: 'realname,nickname,age,job',
          timeout:    '1000'
        }
      };
      var expectedBody = {
        timeout: 1000,
        queries: {
          people: {
            source:  'people',
            condition: {
              query:   'foobar',
              matchTo: ['realname', 'nickname'],
            },
            offset:  10,
            sortBy:  ['-realname', '-nickname'],
            output: {
              attributes: ['realname', 'nickname', 'age', 'job'],
              elements: utils.allElements,
              limit:   100,
            }
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    suite('validation', function() {
      function deepClone(base) {
{'fraction_non_alphanumeric': 0.1301437778879524, 'fraction_numerical': 0.008924144769459593, 'mean_word_length': 1.464874770922419, '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': '1537007', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1082, 'n_words': 223}