<commit_before>/*
 * Test-unit framework for sqlCommands.js
 */

const assert = require('assert');

const vows = require('vows');

const Sql = require('../../src/database/sql-related/sqlCommands');

const sqlCommands = new Sql();

const isNotEmptyTable = function isNotEmptyTable(stringResult) {
  return stringResult !== undefined;
};

const returnTableToMemory = function(tableData) {
  // do nothing for now
};

const sqlCommandsTest = function sqlCommandsTest() {
  this.testCreateTable = function testCreateTable() {
    let preData = '';
    let isPreDataExists = false;
    try {
      sqlCommands.deleteTable('demo');
    } catch (exceptionTableDoesNotExists) {
      preData = sqlCommands.getFullTableData('demo');
      isPreDataExists = true;
    }
    sqlCommands.createTable('CREATE TABLE demo (paramX INT)');
    const tableData = sqlCommands.getFullTableData('demo');
    assert.isTrue(isNotEmptyTable(tableData));
    sqlCommands.deleteTable('demo');
    if (isPreDataExists) {
      returnTableToMemory(preData);
    }
  };

  this.testCreateTable();
};

module.exports = sqlCommandsTest;

sqlCommandsTest();

/* Failed attempt to test on travis
vows.describe('Test SQL Statements').addBatch({
  'table creation': {
    topic: createTable(),

    'create table': CreateTable(topic) {
      DeleteTable(tableName);
      CreateTable(createTableSql);
      const tableData = sqlCommands.getFullTableData('tableName');
      assert.isNotEmptyTable(tableData);
    }
  }
}).export(module);
*/<commit_msg>Add testDeleteTable unitTest of sqlCommands<commit_after>/*
 * Test-unit framework for sqlCommands.js
 */

const assert = require('assert');

const vows = require('vows');

const Sql = require('../../src/database/sql-related/sqlCommands');

const sqlCommands = new Sql();

const isNotEmptyTable = function isNotEmptyTable(stringResult) {
  return stringResult !== undefined;
};

const returnTableToMemory = function(tableData) {
  // do nothing for now
};

const sqlCommandsTest = function sqlCommandsTest() {
  this.testCreateTable = function testCreateTable() {
    let preData = '';
    let isPreDataExists = false;
    try {
      sqlCommands.deleteTable('demo');
    } catch (exceptionTableDoesNotExists) {
      preData = sqlCommands.getFullTableData('demo');
      isPreDataExists = true;
    }
    sqlCommands.createTable('CREATE TABLE demo (paramX INT)');
    const tableData = sqlCommands.getFullTableData('demo');
    assert.isTrue(isNotEmptyTable(tableData));
    sqlCommands.deleteTable('demo');
    if (isPreDataExists) {
      returnTableToMemory(preData);
    }
  };

  this.testDeleteTable = function testDeleteTable() {
    let preData = '';
    let isPreDataExists = false;
    try {
      preData = sqlCommands.getFullTableData('demo');
      isPreDataExists = true;
    } catch (exceptionTableDoesNotExists) {
      //
    }
    sqlCommands.createTable('CREATE TABLE demo (paramX INT)');
    sqlCommands.deleteTable('demo');
    try {
      sqlCommands.getFullTableData('demo');
      assert.isTrue(false);
    } catch (exceptionTableDoesNotExists2) {
      //
    }

    if (isPreDataExists) {
      returnTableToMemory(preData);
    }
  };

  this.testCreateTable();
  this.testDeleteTable();
};

module.exports = sqlCommandsTest;

sqlCommandsTest();

/* Failed attempt to test on travis
vows.describe('Test SQL Statements').addBatch({
  'table creation': {
    topic: createTable(),

    'create table': CreateTable(topic) {
      DeleteTable(tableName);
      CreateTable(createTableSql);
      const tableData = sqlCommands.getFullTableData('tableName');
      assert.isNotEmptyTable(tableData);
    }
  }
}).export(module);
*/
{'fraction_non_alphanumeric': 0.12615803814713897, 'fraction_numerical': 0.00027247956403269756, 'mean_word_length': 3.8687002652519893, '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': '5706416', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1097, 'n_words': 218}