allow versions with -alpha,-rc,-rc.0 .... + don't fail build on version cannot be determined (#196)

Closes #163
This commit is contained in:
Kai Biermeier
2021-01-12 14:50:52 +01:00
committed by GitHub
parent 5b2e80e1a4
commit 56b9864426
3 changed files with 51 additions and 14 deletions

View File

@@ -124,22 +124,22 @@ describe('Versioning', () => {
describe('descriptionRegex', () => {
it('is a valid regex', () => {
expect(Versioning.descriptionRegex).toBeInstanceOf(RegExp);
expect(Versioning.descriptionRegex1).toBeInstanceOf(RegExp);
});
test.each(['v1.1-1-g12345678', 'v0.1-2-g12345678', 'v0.0-500-gA9B6C3D0-dirty'])(
'is happy with valid %s',
(description) => {
expect(Versioning.descriptionRegex.test(description)).toBeTruthy();
expect(Versioning.descriptionRegex1.test(description)).toBeTruthy();
},
);
test.each([undefined, 'v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])(
'does not like %s',
(description) => {
expect(Versioning.descriptionRegex.test(description)).toBeFalsy();
expect(Versioning.descriptionRegex1.test(description)).toBeFalsy();
// Also never expect without the v to work for any of these cases.
expect(Versioning.descriptionRegex.test(description?.substr(1))).toBeFalsy();
expect(Versioning.descriptionRegex1.test(description?.substr(1))).toBeFalsy();
},
);
});
@@ -225,9 +225,7 @@ describe('Versioning', () => {
it('throws when no match could be made', async () => {
jest.spyOn(Versioning, 'getVersionDescription').mockResolvedValue('no-match-can-be-made');
await expect(Versioning.parseSemanticVersion()).rejects.toThrowErrorMatchingInlineSnapshot(
`"Failed to parse git describe output: \\"no-match-can-be-made\\"."`,
);
await expect(Versioning.parseSemanticVersion()).toMatchObject({});
});
});