Skip to content

Commit

Permalink
Fix to dateFormatForLiquibase
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed May 20, 2020
1 parent 0e4b8dc commit 8b9fc47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion generators/generator-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ module.exports = class extends PrivateBase {
let lastLiquibaseTimestamp = this.config.get('lastLiquibaseTimestamp');
if (lastLiquibaseTimestamp) {
lastLiquibaseTimestamp = new Date(lastLiquibaseTimestamp);
if (lastLiquibaseTimestamp > now) {
if (lastLiquibaseTimestamp >= now) {
now = lastLiquibaseTimestamp;
now.setSeconds(now.getSeconds() + 1);
now.setMilliseconds(0);
Expand Down
11 changes: 5 additions & 6 deletions test/generator-base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,21 +433,20 @@ describe('Generator Base', () => {
let firstChangelogDate;
let secondChangelogDate;
beforeEach(() => {
base.options.creationTimestamp = '2000-01-01';
const lastLiquibaseTimestamp = new Date(Date.parse('2030-01-01'));
base.config.set('lastLiquibaseTimestamp', lastLiquibaseTimestamp.getTime());
firstChangelogDate = base.dateFormatForLiquibase(false);
secondChangelogDate = base.dateFormatForLiquibase(false);
});
it('should return a valid changelog date', () => {
expect(/^\d{14}$/.test(firstChangelogDate)).to.be.true;
expect(/^\d{14}$/.test(secondChangelogDate)).to.be.true;
});
it('should return a reproducible changelog date incremental to lastLiquibaseTimestamp', () => {
expect(firstChangelogDate).to.be.equal('20300101000001');
expect(secondChangelogDate).to.be.equal('20300101000002');
expect(firstChangelogDate).to.not.be.equal(secondChangelogDate);
});
it('should save lastLiquibaseTimestamp', () => {
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(parseLiquibaseChangelogDate('20300101000002').getTime());
expect(base.config.get('lastLiquibaseTimestamp')).to.be.equal(
parseLiquibaseChangelogDate(secondChangelogDate).getTime()
);
});
});
describe('with a past creationTimestamp option', () => {
Expand Down

0 comments on commit 8b9fc47

Please sign in to comment.