Skip to content

Commit

Permalink
Merge c279a9b into 7a10113
Browse files Browse the repository at this point in the history
  • Loading branch information
okv committed Jan 24, 2020
2 parents 7a10113 + c279a9b commit 18930c6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 16 additions & 1 deletion test/01-migrator/create/withDateTimeMigrationNumberFormat.js
Expand Up @@ -2,6 +2,7 @@

const tap = require('tap');
const expect = require('expect.js');
const pEachSeries = require('p-each-series');
const testUtils = require('../../../testUtils');

tap.mochaGlobals();
Expand Down Expand Up @@ -38,7 +39,7 @@ describe('migrator create with date time migration number format', () => {
migrator.params.migrationNumberFormat = 'sequentialNumber';
});

it('should create new files with a dateTime prefix', () => {
it('should create migrations without errors', () => {
return Promise.resolve()
.then(() => testUtils.createMigrations({migrator, baseNames}))
.then((migrationNames) => {
Expand All @@ -51,4 +52,18 @@ describe('migrator create with date time migration number format', () => {
expect(name).to.match(new RegExp(`^[0-9]{14}_${baseNames[index]}$`));
});
});

it('created migrations should exist', () => {
return migrator.checkMigrationsExists(names);
});

it('created migrations should be loadable', () => {
return pEachSeries(names, (name) => migrator.loadMigration(name));
});

it('created migrations should be listed as `new`', () => {
return Promise.resolve()
.then(() => migrator.getNewMigrationNames())
.then((newNames) => expect(newNames).eql(names));
});
});
Expand Up @@ -31,7 +31,7 @@ describe('migrator create with sequential migration number format', () => {

after(() => testUtils.destroyEnv(testEnv));

it('should create migrations sequentially without errors', () => {
it('should create migrations without errors', () => {
return Promise.resolve()
.then(() => testUtils.createMigrations({migrator, baseNames}))
.then((migrationNames) => {
Expand Down
7 changes: 5 additions & 2 deletions testUtils/createMigrator.js
Expand Up @@ -16,6 +16,8 @@ module.exports = (params) => {

return Promise.resolve()
.then(() => migrator.configure(params.configureParams))
// always connect migrator coz `removeDirBefore` makes unmark executed
.then(() => migrator.connect())
.then(() => {
if (params.removeDirBefore) {
return removeMigratorDir(migrator);
Expand All @@ -27,8 +29,9 @@ module.exports = (params) => {
}
})
.then(() => {
if (params.connect) {
return migrator.connect();
// disconnect if connected was not required
if (!params.connect) {
return migrator.disconnect();
}
})
.then(() => migrator);
Expand Down

0 comments on commit 18930c6

Please sign in to comment.