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

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

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

suite('building message from REST API request', function() {
  suite('search', function() {
    var outputAll = {
      startTime:   true,
      elapsedTime: true,
      count:       true,
      attributes:  true,
      recodes:     true
    };

    test('simple query', function() {
      var fakeRequest = {
        params: {
          tableName: 'test_table'
        },
        query: {
          query: 'foobar'
        }
      };
      var expectedBody = {
        queries: {
          result: {
            source: 'test_table',
            query:  'foobar',
            output: outputAll
          }
        }
      };
      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',
            query:   'foobar',
            offset:  10,
            limit:   100,
            matchTo: ['realname', 'nickname'],
            sortBy:  ['-realname', '-nickname'],
            attributes: ['realname', 'nickname', 'age', 'job'],
            output:  outputAll
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    suite('validation', function() {
      function deepClone(base) {
        if (!base || typeof base != 'object')
          return base;<commit_msg>Specify fake query parameters as strings<commit_after>var assert = require('chai').assert;

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

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

suite('building message from REST API request', function() {
  suite('search', function() {
    var outputAll = {
      startTime:   true,
      elapsedTime: true,
      count:       true,
      attributes:  true,
      recodes:     true
    };

    test('simple query', function() {
      var fakeRequest = {
        params: {
          tableName: 'test_table'
        },
        query: {
          query: 'foobar'
        }
      };
      var expectedBody = {
        queries: {
          result: {
            source: 'test_table',
            query:  'foobar',
            output: outputAll
          }
        }
      };
      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',
            query:   'foobar',
            offset:  10,
            limit:   100,
            matchTo: ['realname', 'nickname'],
            sortBy:  ['-realname', '-nickname'],
            attributes: ['realname', 'nickname', 'age', 'job'],
            output:  outputAll
          }
        }
      };
      var actualBody = builders.search(fakeRequest);
      assert.equalJSON(actualBody, expectedBody);
    });

    suite('validation', function() {
      function deepClone(base) {
        if (!base || typeof base != 'object')
          return base;
{'fraction_non_alphanumeric': 0.13053263315828958, 'fraction_numerical': 0.00900225056264066, 'mean_word_length': 1.5974025974025974, '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': '5088444', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1107, 'n_words': 248}