dealing with conflicts (#8772)

This commit is contained in:
matt korwel
2025-09-18 17:33:08 -07:00
committed by GitHub
parent 29852e9b08
commit b14a4f5ebc
6 changed files with 143 additions and 39 deletions

View File

@@ -21,7 +21,7 @@ describe('getVersion', () => {
if (command.includes('npm view') && command.includes('--tag=latest'))
return '0.4.1';
if (command.includes('npm view') && command.includes('--tag=preview'))
return '0.5.0-preview-2';
return '0.5.0-preview.2';
if (command.includes('npm view') && command.includes('--tag=nightly'))
return '0.6.0-nightly.20250910.a31830a3';
@@ -29,14 +29,14 @@ describe('getVersion', () => {
if (command.includes("git tag --sort=-creatordate -l 'v[0-9].[0-9].[0-9]'"))
return 'v0.4.1';
if (command.includes("git tag --sort=-creatordate -l 'v*-preview*'"))
return 'v0.5.0-preview-2';
return 'v0.5.0-preview.2';
if (command.includes("git tag --sort=-creatordate -l 'v*-nightly*'"))
return 'v0.6.0-nightly.20250910.a31830a3';
// GitHub Release Mocks
if (command.includes('gh release view "v0.4.1"')) return 'v0.4.1';
if (command.includes('gh release view "v0.5.0-preview-2"'))
return 'v0.5.0-preview-2';
if (command.includes('gh release view "v0.5.0-preview.2"'))
return 'v0.5.0-preview.2';
if (command.includes('gh release view "v0.6.0-nightly.20250910.a31830a3"'))
return 'v0.6.0-nightly.20250910.a31830a3';
@@ -71,7 +71,7 @@ describe('getVersion', () => {
const result = getVersion({ type: 'preview' });
expect(result.releaseVersion).toBe('0.6.0-preview.0');
expect(result.npmTag).toBe('preview');
expect(result.previousReleaseTag).toBe('v0.5.0-preview-2');
expect(result.previousReleaseTag).toBe('v0.5.0-preview.2');
});
it('should use the override version for preview if provided', () => {
@@ -82,7 +82,7 @@ describe('getVersion', () => {
});
expect(result.releaseVersion).toBe('4.5.6-preview.0');
expect(result.npmTag).toBe('preview');
expect(result.previousReleaseTag).toBe('v0.5.0-preview-2');
expect(result.previousReleaseTag).toBe('v0.5.0-preview.2');
});
it('should calculate the next nightly version from the latest nightly', () => {
@@ -106,9 +106,9 @@ describe('getVersion', () => {
it('should calculate the next patch version for a preview release', () => {
vi.mocked(execSync).mockImplementation(mockExecSync);
const result = getVersion({ type: 'patch', 'patch-from': 'preview' });
expect(result.releaseVersion).toBe('0.5.1-preview-2');
expect(result.releaseVersion).toBe('0.5.0-preview.3');
expect(result.npmTag).toBe('preview');
expect(result.previousReleaseTag).toBe('v0.5.0-preview-2');
expect(result.previousReleaseTag).toBe('v0.5.0-preview.2');
});
});
@@ -160,13 +160,13 @@ describe('getVersion', () => {
vi.mocked(execSync).mockImplementation(mockWithMismatchGitTag);
expect(() => getVersion({ type: 'stable' })).toThrow(
'Discrepancy found! NPM preview tag (0.5.0-preview-2) does not match latest git preview tag (v0.4.0-preview-99).',
'Discrepancy found! NPM preview tag (0.5.0-preview.2) does not match latest git preview tag (v0.4.0-preview-99).',
);
});
it('should throw an error if the GitHub release is missing', () => {
const mockWithMissingRelease = (command) => {
if (command.includes('gh release view "v0.5.0-preview-2"')) {
if (command.includes('gh release view "v0.5.0-preview.2"')) {
throw new Error('gh command failed'); // Simulate gh failure
}
return mockExecSync(command);
@@ -174,7 +174,7 @@ describe('getVersion', () => {
vi.mocked(execSync).mockImplementation(mockWithMissingRelease);
expect(() => getVersion({ type: 'stable' })).toThrow(
'Discrepancy found! Failed to verify GitHub release for v0.5.0-preview-2.',
'Discrepancy found! Failed to verify GitHub release for v0.5.0-preview.2.',
);
});
});