mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-08-25 19:43:50 +00:00
Add latest-known version selector (#993)
## Summary - add `latest-known` as an explicit version selector - resolve it locally to the newest version in the bundled checksum table - preserve existing default and `latest` behavior - document custom-manifest checksum semantics and update published bundles ## Testing - `npm ci --ignore-scripts` - `npm run all` (99 tests passed) Closes #919 Refs: pi-session 019fed0e-6019-7504-911b-bd9955cbbd49
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { expect, it, jest } from "@jest/globals";
|
||||
|
||||
jest.unstable_mockModule(
|
||||
"../../../src/download/checksum/known-checksums",
|
||||
() => ({
|
||||
KNOWN_CHECKSUMS: {
|
||||
"aarch64-apple-darwin-1.9.0": "checksum",
|
||||
"x86_64-unknown-linux-gnu-1.8.0": "checksum",
|
||||
"x86_64-unknown-linux-gnu-1.10.0": "checksum",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const { getLatestKnownVersion } = await import(
|
||||
"../../../src/download/checksum/known-version"
|
||||
);
|
||||
|
||||
it("returns the highest version with a built-in checksum", () => {
|
||||
expect(getLatestKnownVersion()).toBe("1.10.0");
|
||||
});
|
||||
@@ -55,6 +55,12 @@ jest.unstable_mockModule("../../src/download/checksum/checksum", () => ({
|
||||
validateChecksum: mockValidateChecksum,
|
||||
}));
|
||||
|
||||
const mockGetLatestKnownVersion = jest.fn(() => "0.9.25");
|
||||
|
||||
jest.unstable_mockModule("../../src/download/checksum/known-version", () => ({
|
||||
getLatestKnownVersion: mockGetLatestKnownVersion,
|
||||
}));
|
||||
|
||||
const { downloadVersion, resolveVersion, rewriteToMirror } = await import(
|
||||
"../../src/download/download-version"
|
||||
);
|
||||
@@ -72,6 +78,7 @@ describe("download-version", () => {
|
||||
mockGetFirstMatchingVersion.mockReset();
|
||||
mockGetArtifact.mockReset();
|
||||
mockValidateChecksum.mockReset();
|
||||
mockGetLatestKnownVersion.mockClear();
|
||||
|
||||
mockDownloadTool.mockResolvedValue("/tmp/downloaded");
|
||||
mockExtractTar.mockResolvedValue("/tmp/extracted");
|
||||
@@ -90,6 +97,16 @@ describe("download-version", () => {
|
||||
expect(mockGetLatestVersion).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
|
||||
it("resolves latest-known without reading the manifest", async () => {
|
||||
const version = await resolveVersion("latest-known", undefined);
|
||||
|
||||
expect(version).toBe("0.9.25");
|
||||
expect(mockGetLatestKnownVersion).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetLatestVersion).not.toHaveBeenCalled();
|
||||
expect(mockGetAllVersions).not.toHaveBeenCalled();
|
||||
expect(mockGetFirstMatchingVersion).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stops at the first matching version in the default manifest", async () => {
|
||||
mockGetFirstMatchingVersion.mockImplementation(
|
||||
(predicate: (version: string) => boolean) =>
|
||||
|
||||
Reference in New Issue
Block a user