import { expect } from 'chai'; import { getMysqlTableSql } from '../../src/generate-table-sql/mysql'; describe('generate-table-sql/mysql', () => { beforeEach(() => { }); afterEach(async () => { }); it('生成单个MySQL建表语句', () => { const str = getMysqlTableSql({ databaseName: 'sample', tableName: 'origin_user_whole', tableComment: '原始数据-用户注册表', primaryKey: 'user_id', columns: [ { name: 'user_id', type: 'VARCHAR(32)', comment: '用户id', }, { name: 'register_time', type: 'INT', defaultValue: 'NULL', comment: '注册时间', }, ], }); expect(str).to.be.equal([ 'DROP TABLE IF EXISTS sample.origin_user_whole;', 'CREATE TABLE sample.origin_user_whole (', ' user_id VARCHAR(32) NOT NULL PRIMARY KEY COMMENT "用户id",', ' register_time INT DEFAULT NULL COMMENT "注册时间",', ' INDEX (register_time)', ') COMMENT "原始数据-用户注册表";', ].join('\n')); }); });