Skip to content

Commit

Permalink
cleanup: upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pateketrueke committed Jul 15, 2023
1 parent 426a78e commit ef72810
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions tests/umzug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ describe('Umzug support', () => {
await JSONSchemaSequelizerCLI.execute(db, 'migrate', { flags: { make: true } });
const { calls } = td.explain(log);

expect(calls.pop().args[0]).to.match(/write.*create_family/);
expect(calls.pop().args[0]).to.match(/write.*create_blog/);
expect(calls.pop().args[0]).to.match(/write.*create_person/);
expect(calls.pop().args[0]).to.match(/write.*create_post/);
const migration = calls.filter(x => x.args[0].includes('create_')).map(x => x.args[0].replace(/\d+\.\d+\./, ''));

expect(migration).to.eql([
'\rwrite tests/sandbox/migrations/0_create_person.js',
'\rwrite tests/sandbox/migrations/1_create_post.js',
'\rwrite tests/sandbox/migrations/2_create_blog.js',
'\rwrite tests/sandbox/migrations/3_create_family.js',
]);
});

it('can apply pending migrations from generated sources', async () => {
Expand All @@ -64,22 +68,23 @@ describe('Umzug support', () => {
const { calls } = td.explain(log);

expect(calls.pop().args).to.eql(['\r4 migrations were applied']);
expect(calls.pop().args[0]).to.match(/migrated.*create_family/);
calls.length -= 5;

expect(calls.pop().args[0]).to.match(/migrating.*create_family/);
expect(calls.pop().args[0]).to.match(/migrated.*create_blog/);
calls.length -= 5;

expect(calls.pop().args[0]).to.match(/migrating.*create_blog/);
expect(calls.pop().args[0]).to.match(/migrated.*create_person/);
calls.length -= 5;

expect(calls.pop().args[0]).to.match(/migrating.*create_person/);
expect(calls.pop().args[0]).to.match(/migrated.*create_post/);
calls.length -= 5;

expect(calls.pop().args[0]).to.match(/migrating.*create_post/);
const migration = calls.filter(x => x.args[0].includes('create_')).map(x => x.args[0].replace(/\d+\.\d+\./, ''));

expect(migration).to.eql([
'\rwrite tests/sandbox/migrations/0_create_person.js',
'\rwrite tests/sandbox/migrations/1_create_post.js',
'\rwrite tests/sandbox/migrations/2_create_blog.js',
'\rwrite tests/sandbox/migrations/3_create_family.js',
'\r=> migrating 0_create_person.js',
'\r=> migrated 0_create_person.js',
'\r=> migrating 1_create_post.js',
'\r=> migrated 1_create_post.js',
'\r=> migrating 2_create_blog.js',
'\r=> migrated 2_create_blog.js',
'\r=> migrating 3_create_family.js',
'\r=> migrated 3_create_family.js',
]);
});
});
});

0 comments on commit ef72810

Please sign in to comment.