mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-03 01:40:59 -07:00
Pre releases (#10752)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
cloneFromGit,
|
||||
extractFile,
|
||||
findReleaseAsset,
|
||||
fetchReleaseFromGithub,
|
||||
parseGitHubRepoForReleases,
|
||||
} from './github.js';
|
||||
import { simpleGit, type SimpleGit } from 'simple-git';
|
||||
@@ -35,6 +36,15 @@ vi.mock('node:os', async (importOriginal) => {
|
||||
|
||||
vi.mock('simple-git');
|
||||
|
||||
const fetchJsonMock = vi.hoisted(() => vi.fn());
|
||||
vi.mock('./github_fetch.js', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('./github_fetch.js')>();
|
||||
return {
|
||||
...actual,
|
||||
fetchJson: fetchJsonMock,
|
||||
};
|
||||
});
|
||||
|
||||
describe('git extension helpers', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -223,6 +233,66 @@ describe('git extension helpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchReleaseFromGithub', () => {
|
||||
it('should fetch the latest release if allowPreRelease is true', async () => {
|
||||
const releases = [{ tag_name: 'v1.0.0-alpha' }, { tag_name: 'v0.9.0' }];
|
||||
fetchJsonMock.mockResolvedValueOnce(releases);
|
||||
|
||||
const result = await fetchReleaseFromGithub(
|
||||
'owner',
|
||||
'repo',
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
|
||||
expect(fetchJsonMock).toHaveBeenCalledWith(
|
||||
'https://api.github.com/repos/owner/repo/releases?per_page=1',
|
||||
);
|
||||
expect(result).toEqual(releases[0]);
|
||||
});
|
||||
|
||||
it('should fetch the latest release if allowPreRelease is false', async () => {
|
||||
const release = { tag_name: 'v0.9.0' };
|
||||
fetchJsonMock.mockResolvedValueOnce(release);
|
||||
|
||||
const result = await fetchReleaseFromGithub(
|
||||
'owner',
|
||||
'repo',
|
||||
undefined,
|
||||
false,
|
||||
);
|
||||
|
||||
expect(fetchJsonMock).toHaveBeenCalledWith(
|
||||
'https://api.github.com/repos/owner/repo/releases/latest',
|
||||
);
|
||||
expect(result).toEqual(release);
|
||||
});
|
||||
|
||||
it('should fetch a release by tag if ref is provided', async () => {
|
||||
const release = { tag_name: 'v0.9.0' };
|
||||
fetchJsonMock.mockResolvedValueOnce(release);
|
||||
|
||||
const result = await fetchReleaseFromGithub('owner', 'repo', 'v0.9.0');
|
||||
|
||||
expect(fetchJsonMock).toHaveBeenCalledWith(
|
||||
'https://api.github.com/repos/owner/repo/releases/tags/v0.9.0',
|
||||
);
|
||||
expect(result).toEqual(release);
|
||||
});
|
||||
|
||||
it('should fetch latest stable release if allowPreRelease is undefined', async () => {
|
||||
const release = { tag_name: 'v0.9.0' };
|
||||
fetchJsonMock.mockResolvedValueOnce(release);
|
||||
|
||||
const result = await fetchReleaseFromGithub('owner', 'repo');
|
||||
|
||||
expect(fetchJsonMock).toHaveBeenCalledWith(
|
||||
'https://api.github.com/repos/owner/repo/releases/latest',
|
||||
);
|
||||
expect(result).toEqual(release);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findReleaseAsset', () => {
|
||||
const assets = [
|
||||
{ name: 'darwin.arm64.extension.tar.gz', browser_download_url: 'url1' },
|
||||
|
||||
Reference in New Issue
Block a user