rochejul / sequelize-mocking

Sequelize extension to deal with data-mocking for testing
MIT License
63 stars 26 forks source link

Add afterhook name #20

Closed pacoccino closed 6 years ago

pacoccino commented 6 years ago

When running consecutive tests, the hooks are not removed and models creation in database cumulates.

see https://github.com/sequelize/sequelize/blob/master/lib/hooks.js#L184 and http://docs.sequelizejs.com/manual/tutorial/hooks.html#removing-hooks

pacoccino commented 6 years ago

Example after 5th test :

SequelizeMocking - Mock the context
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Candle` (`id` UUID PRIMARY KEY, `date` DATETIME NOT NULL, `open` DECIMAL NOT NULL, `high` DECIMAL NOT NULL, `low` DECIMAL NOT NULL, `close` DECIMAL NOT NULL, `vwap` DECIMAL NOT NULL, `PairId` UUID REFERENCES `Pair` (`id`) ON DELETE SET NULL ON UPDATE CASCADE);
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Coin` (`id` UUID PRIMARY KEY, `name` VARCHAR(255) NOT NULL UNIQUE, `code` VARCHAR(255) NOT NULL UNIQUE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`name`), UNIQUE (`code`));
Executing (default): CREATE TABLE IF NOT EXISTS `Exchange` (`name` VARCHAR(255) NOT NULL PRIMARY KEY, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): CREATE TABLE IF NOT EXISTS `Exchange` (`name` VARCHAR(255) NOT NULL PRIMARY KEY, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);

after dozen of tests heap size just crash

rochejul commented 6 years ago

Many thanks for your contribution and fix

I try to publish the 1.2.1 release as soon as possible

Many thanks again

Regards