test/lib/init-models.js
/**
 * @function beforeEach
 *
 * shared initialization for tests
 */
@function beforeEach
shared initialization for tests
@function beforeEach shared initialization for tests
async function initModels (args) {
    ImmutableCore.reset()
    ImmutableCoreModel.reset()
    ImmutableGlobal.reset()
    const mysql = await ImmutableCoreModel.createMysqlConnection(connectionParams)
    await mysql.query('DROP TABLE IF EXISTS task')
    await mysql.query('DROP TABLE IF EXISTS taskInstance')
    var taskModelGlobal = new ImmutableCoreModel({
        columns: {
            name: {
                immutable: true,
                type: 'string',
                unique: true,
            },
        },
        compression: false,
        mysql: mysql,
        name: 'task',
    })
    var instanceModelGlboal = new ImmutableCoreModel({
        columns: {
            nextRunTime: {
                index: true,
                null: true,
                type: 'time',
            },
            taskId: {
                index: true,
                null: false,
                type: 'id',
            },
        },
        compression: false,
        mysql: mysql,
        name: 'taskInstance',
    })
    await taskModelGlobal.sync()
    await instanceModelGlboal.sync()
    var taskModel = taskModelGlobal.session(args.session)
    var instanceModel = instanceModelGlboal.session(args.session)
    return {instanceModel, mysql, taskModel}
}
async function initModels ( args ) { ImmutableCore . reset ( ) ImmutableCoreModel . reset ( ) ImmutableGlobal . reset ( ) const mysql = await ImmutableCoreModel . createMysqlConnection ( connectionParams ) await mysql . query ( 'DROP TABLE IF EXISTS task' ) await mysql . query ( 'DROP TABLE IF EXISTS taskInstance' ) var taskModelGlobal = new ImmutableCoreModel ( { columns : { name : { immutable : true , type : 'string' , unique : true , } , } , compression : false , mysql : mysql , name : 'task' , } ) var instanceModelGlboal = new ImmutableCoreModel ( { columns : { nextRunTime : { index : true , null : true , type : 'time' , } , taskId : { index : true , null : false , type : 'id' , } , } , compression : false , mysql : mysql , name : 'taskInstance' , } ) await taskModelGlobal . sync ( ) await instanceModelGlboal . sync ( ) var taskModel = taskModelGlobal . session ( args . session ) var instanceModel = instanceModelGlboal . session ( args . session ) return { instanceModel , mysql , taskModel } }
@function beforeEach
 shared initialization for tests
@function beforeEach shared initialization for tests
// reset global data // create mysql client // drop any test tables if they exist // create task model // create instance model // sync models // get local models