<commit_before>/* jslint node: true */
/* Copyright (c) 2012 <NAME> */
/*
 * These tests assume a MySQL database/structure is already created.
 * execute script/schema.sql to create
 */

'use strict'

var _ = require('lodash')
var Seneca = require('seneca')
var Shared = require('seneca-store-test')
var Extra = require('./mysql.ext.test.js')
var Autoincrement = require('./mysql.autoincrement.test.js')
var Fs = require('fs')

var Lab = require('lab')
var lab = exports.lab = Lab.script()
const { before, after } = lab
var describe = lab.describe

var dbConfig = require('./support/db/config')


var si = Seneca({
  default_plugins: {
    'mem-store': false
  }
})

if (si.version >= '2.0.0') {
  si.use('entity')
}

describe('MySQL suite tests ', function () {
  before({}, function (done) {
    si.use(require('../mysql-store.js'), dbConfig)
    si.ready(done)
  })

  after({}, function (done) {
    si.close(done)
  })

  Shared.basictest({
    seneca: si,
    script: lab
  })

  Shared.sorttest({
    seneca: si,
    script: lab
  })

  Shared.limitstest({
    seneca: si,
    script: lab
  })

  Shared.sqltest({
    seneca: si,
    script: lab
  })

  Extra.extendTest({
    seneca: si,
    script: lab
  })
})

var incrementConfig = _.assign({}, dbConfig, {
  map: {'-/-/incremental': '*'},
  auto_increment: true
})

var si2 = Seneca({
  default_plugins: {
    'mem-store': false
  }
})

if (si2.version >= '2.0.0') {
  si2.use('entity')
}

describe('MySQL autoincrement tests ', function () {
  before({}, function (done) {
    si2.use(require('../mysql-store.js'), incrementConfig)
    si2.ready(done)
  })

  after({}, function (done) {
    si2.close(done)
  })

  Autoincrement.autoincrementTest({
    seneca: si2,
    script: lab
  })
})<commit_msg>Tidy up<commit_after>/* jslint node: true */
/* Copyright (c) 2012 <NAME> */
/*
 * These tests assume a MySQL database/structure is already created.
 * execute script/schema.sql to create
 */

'use strict'

var _ = require('lodash')
var Seneca = require('seneca')
var Shared = require('seneca-store-test')
var Extra = require('./mysql.ext.test.js')
var Autoincrement = require('./mysql.autoincrement.test.js')

var Lab = require('lab')
var lab = exports.lab = Lab.script()
const { describe, before, after } = lab

const DbConfig = require('./support/db/config')


describe('MySQL suite tests ', function () {
  const si = makeSeneca({ mysqlStoreOpts: DbConfig })

  before({}, function (done) {
    si.ready(done)
  })

  after({}, function (done) {
    si.close(done)
  })

  Shared.basictest({
    seneca: si,
    script: lab
  })

  Shared.sorttest({
    seneca: si,
    script: lab
  })

  Shared.limitstest({
    seneca: si,
    script: lab
  })

  Shared.sqltest({
    seneca: si,
    script: lab
  })

  Extra.extendTest({
    seneca: si,
    script: lab
  })
})


describe('MySQL autoincrement tests ', function () {
  const incrementConfig = _.assign({}, DbConfig, {
    map: {'-/-/incremental': '*'},
    auto_increment: true
  })

  const si2 = makeSeneca({
    mysqlStoreOpts: incrementConfig
  })


  before({}, function (done) {
    si2.ready(done)
  })

  after({}, function (done) {
    si2.close(done)
  })

  Autoincrement.autoincrementTest({
    seneca: si2,
    script: lab
  })
})


function makeSeneca (opts = {}) {
  const si = Seneca({
    default_plugins: {
      'mem-store': false
    }
  })

  if (si.version >= '2.0.0') {
    si.use('entity')
  }

  const { mysqlStoreOpts = {} } = opts
  si.use(require('../mysql-store.js'), mysqlStoreOpts)

  return si
}

{'fraction_non_alphanumeric': 0.17234581807941424, 'fraction_numerical': 0.007885102787947058, 'mean_word_length': 3.031782065834279, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '2837222', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1238, 'n_words': 288}