2020-03-20 20:28:31 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { nextVersion } from '../script/release/version-bumper';
|
|
|
|
import * as utils from '../script/release/version-utils';
|
|
|
|
import { ifdescribe } from './spec-helpers';
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
describe('version-bumper', () => {
|
|
|
|
describe('makeVersion', () => {
|
|
|
|
it('makes a version with a period delimeter', () => {
|
|
|
|
const components = {
|
|
|
|
major: 2,
|
|
|
|
minor: 0,
|
|
|
|
patch: 0
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2019-07-24 17:16:28 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = utils.makeVersion(components, '.');
|
|
|
|
expect(version).to.equal('2.0.0');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('makes a version with a period delimeter and a partial pre', () => {
|
|
|
|
const components = {
|
|
|
|
major: 2,
|
|
|
|
minor: 0,
|
|
|
|
patch: 0,
|
2020-03-20 15:12:18 +00:00
|
|
|
pre: ['nightly', 12345678]
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2019-07-24 17:16:28 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = utils.makeVersion(components, '.', utils.preType.PARTIAL);
|
|
|
|
expect(version).to.equal('2.0.0.12345678');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('makes a version with a period delimeter and a full pre', () => {
|
|
|
|
const components = {
|
|
|
|
major: 2,
|
|
|
|
minor: 0,
|
|
|
|
patch: 0,
|
2020-03-20 15:12:18 +00:00
|
|
|
pre: ['nightly', 12345678]
|
2020-03-20 20:28:31 +00:00
|
|
|
};
|
2019-07-24 17:16:28 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = utils.makeVersion(components, '.', utils.preType.FULL);
|
|
|
|
expect(version).to.equal('2.0.0-nightly.12345678');
|
|
|
|
});
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
// On macOS Circle CI we don't have a real git environment due to running
|
|
|
|
// gclient sync on a linux machine. These tests therefore don't run as expected.
|
2019-10-30 23:38:21 +00:00
|
|
|
ifdescribe(!(process.platform === 'linux' && process.arch === 'arm') && process.platform !== 'darwin')('nextVersion', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const nightlyPattern = /[0-9.]*(-nightly.(\d{4})(\d{2})(\d{2}))$/g;
|
|
|
|
const betaPattern = /[0-9.]*(-beta[0-9.]*)/g;
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to nightly from stable', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0';
|
|
|
|
const next = await nextVersion('nightly', version);
|
|
|
|
const matches = next.match(nightlyPattern);
|
|
|
|
expect(matches).to.have.lengthOf(1);
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to nightly from beta', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-beta.1';
|
|
|
|
const next = await nextVersion('nightly', version);
|
|
|
|
const matches = next.match(nightlyPattern);
|
|
|
|
expect(matches).to.have.lengthOf(1);
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to nightly from nightly', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-nightly.19950901';
|
|
|
|
const next = await nextVersion('nightly', version);
|
|
|
|
const matches = next.match(nightlyPattern);
|
|
|
|
expect(matches).to.have.lengthOf(1);
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
2019-11-12 16:36:03 +00:00
|
|
|
it('bumps to a nightly version above our switch from N-0-x to N-x-y branch names', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-nightly.19950901';
|
|
|
|
const next = await nextVersion('nightly', version);
|
2019-11-12 16:36:03 +00:00
|
|
|
// If it starts with v8 then we didn't bump above the 8-x-y branch
|
2020-03-20 20:28:31 +00:00
|
|
|
expect(next.startsWith('v8')).to.equal(false);
|
|
|
|
});
|
2019-11-12 16:36:03 +00:00
|
|
|
|
2019-07-24 17:16:28 +00:00
|
|
|
it('throws error when bumping to beta from stable', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0';
|
2019-07-24 17:16:28 +00:00
|
|
|
return expect(
|
|
|
|
nextVersion('beta', version)
|
2020-03-20 20:28:31 +00:00
|
|
|
).to.be.rejectedWith('Cannot bump to beta from stable.');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to beta from nightly', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-nightly.19950901';
|
|
|
|
const next = await nextVersion('beta', version);
|
|
|
|
const matches = next.match(betaPattern);
|
|
|
|
expect(matches).to.have.lengthOf(1);
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to beta from beta', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-beta.8';
|
|
|
|
const next = await nextVersion('beta', version);
|
|
|
|
expect(next).to.equal('2.0.0-beta.9');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to stable from beta', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-beta.1';
|
|
|
|
const next = await nextVersion('stable', version);
|
|
|
|
expect(next).to.equal('2.0.0');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('bumps to stable from stable', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0';
|
|
|
|
const next = await nextVersion('stable', version);
|
|
|
|
expect(next).to.equal('2.0.1');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
2019-10-23 18:07:10 +00:00
|
|
|
it('bumps to minor from stable', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0';
|
|
|
|
const next = await nextVersion('minor', version);
|
|
|
|
expect(next).to.equal('2.1.0');
|
|
|
|
});
|
2019-10-23 18:07:10 +00:00
|
|
|
|
2019-07-24 17:16:28 +00:00
|
|
|
it('bumps to stable from nightly', async () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0-nightly.19950901';
|
|
|
|
const next = await nextVersion('stable', version);
|
|
|
|
expect(next).to.equal('2.0.0');
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('throws on an invalid version', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'vI.AM.INVALID';
|
2019-07-24 17:16:28 +00:00
|
|
|
return expect(
|
|
|
|
nextVersion('beta', version)
|
2020-03-20 20:28:31 +00:00
|
|
|
).to.be.rejectedWith(`Invalid current version: ${version}`);
|
|
|
|
});
|
2019-07-24 17:16:28 +00:00
|
|
|
|
|
|
|
it('throws on an invalid bump type', () => {
|
2020-03-20 20:28:31 +00:00
|
|
|
const version = 'v2.0.0';
|
2019-07-24 17:16:28 +00:00
|
|
|
return expect(
|
|
|
|
nextVersion('WRONG', version)
|
2020-03-20 20:28:31 +00:00
|
|
|
).to.be.rejectedWith('Invalid bump type.');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|