@@ -17,11 +17,12 @@ const {
1717 fetchManifest,
1818 getAllVersions,
1919 getArtifact,
20+ getLatestVersion,
2021 parseManifest,
2122} = await import ( "../../src/download/manifest" ) ;
2223
23- const sampleManifestResponse = `{"version":"0.9.25 ","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25 /uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6 "}]}
24- {"version":"0.9.26 ","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26 /uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036 "}]}` ;
24+ const sampleManifestResponse = `{"version":"0.9.26 ","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26 /uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"fcf0a9ea6599c6ae28a4c854ac6da76f2c889354d7c36ce136ef071f7ab9721f"},{"platform":"x86_64-pc-windows-msvc","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-x86_64-pc-windows-msvc.zip","archive_format":"zip","sha256":"eb02fd95d8e0eed462b4a67ecdd320d865b38c560bffcda9a0b87ec944bdf036 "}]}
25+ {"version":"0.9.25 ","artifacts":[{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.25 /uv-aarch64-apple-darwin.tar.gz","archive_format":"tar.gz","sha256":"606b3c6949d971709f2526fa0d9f0fd23ccf60e09f117999b406b424af18a6a6 "}]}` ;
2526
2627const multiVariantManifestResponse = `{"version":"0.9.26","artifacts":[{"platform":"aarch64-apple-darwin","variant":"python-managed","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin-managed.tar.gz","archive_format":"tar.gz","sha256":"managed-checksum"},{"platform":"aarch64-apple-darwin","variant":"default","url":"https://github.com/astral-sh/uv/releases/download/0.9.26/uv-aarch64-apple-darwin.zip","archive_format":"zip","sha256":"default-checksum"}]}` ;
2728
@@ -54,8 +55,8 @@ describe("manifest", () => {
5455 const versions = await fetchManifest ( ) ;
5556
5657 expect ( versions ) . toHaveLength ( 2 ) ;
57- expect ( versions [ 0 ] ?. version ) . toBe ( "0.9.25 " ) ;
58- expect ( versions [ 1 ] ?. version ) . toBe ( "0.9.26 " ) ;
58+ expect ( versions [ 0 ] ?. version ) . toBe ( "0.9.26 " ) ;
59+ expect ( versions [ 1 ] ?. version ) . toBe ( "0.9.25 " ) ;
5960 } ) ;
6061
6162 it ( "throws on a failed fetch" , async ( ) => {
@@ -90,7 +91,19 @@ describe("manifest", () => {
9091 "https://example.com/custom.ndjson" ,
9192 ) ;
9293
93- expect ( versions ) . toEqual ( [ "0.9.25" , "0.9.26" ] ) ;
94+ expect ( versions ) . toEqual ( [ "0.9.26" , "0.9.25" ] ) ;
95+ } ) ;
96+ } ) ;
97+
98+ describe ( "getLatestVersion" , ( ) => {
99+ it ( "returns the first version string" , async ( ) => {
100+ mockFetch . mockResolvedValue (
101+ createMockResponse ( true , 200 , "OK" , sampleManifestResponse ) ,
102+ ) ;
103+
104+ await expect (
105+ getLatestVersion ( "https://example.com/custom.ndjson" ) ,
106+ ) . resolves . toBe ( "0.9.26" ) ;
94107 } ) ;
95108 } ) ;
96109
0 commit comments