From 4a3568a0310a71fbaff78826fe8f8fca68861f3d Mon Sep 17 00:00:00 2001 From: Techatrix Date: Tue, 6 Aug 2024 05:45:00 +0200 Subject: [PATCH] assert length of file shasum --- src/select-zls-version.ts | 1 + test/select-zls-version.test.ts | 39 ++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/select-zls-version.ts b/src/select-zls-version.ts index bc5be50..aaa8c56 100644 --- a/src/select-zls-version.ts +++ b/src/select-zls-version.ts @@ -117,6 +117,7 @@ function artifactsToRecord( break; } assert(!(`${artifact.arch}-${artifact.os}` in targets)); + assert.strictEqual(artifact.fileShasum.length, 64); targets[`${artifact.arch}-${artifact.os}`] = { tarball: `${env.R2_PUBLIC_URL}/zls-${artifact.os}-${artifact.arch}-${artifact.version}.${artifact.extension}`, shasum: artifact.fileShasum, diff --git a/test/select-zls-version.test.ts b/test/select-zls-version.test.ts index 73c5a7d..77b8f10 100644 --- a/test/select-zls-version.test.ts +++ b/test/select-zls-version.test.ts @@ -23,7 +23,8 @@ const defaultArtifacts: ReleaseArtifact[] = [ os: "linux", version: "0.11.0", extension: "tar.xz", - fileShasum: "aaa", + fileShasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", fileSize: 12, }, { @@ -31,7 +32,8 @@ const defaultArtifacts: ReleaseArtifact[] = [ os: "linux", version: "0.11.0", extension: "tar.gz", - fileShasum: "bbb", + fileShasum: + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", fileSize: 12, }, { @@ -39,7 +41,8 @@ const defaultArtifacts: ReleaseArtifact[] = [ os: "windows", version: "0.11.0", extension: "zip", - fileShasum: "ccc", + fileShasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", fileSize: 12, }, ]; @@ -247,12 +250,14 @@ describe("/v1/zls/index.json", () => { date: "1970-01-01", "x86_64-linux": { tarball: `${env.R2_PUBLIC_URL}/zls-linux-x86_64-0.11.0.tar.xz`, - shasum: "aaa", + shasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", size: "12", }, "aarch64-windows": { tarball: `${env.R2_PUBLIC_URL}/zls-windows-aarch64-0.11.0.zip`, - shasum: "ccc", + shasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", size: "12", }, }, @@ -260,12 +265,14 @@ describe("/v1/zls/index.json", () => { date: "1970-01-01", "x86_64-linux": { tarball: `${env.R2_PUBLIC_URL}/zls-linux-x86_64-0.11.0.tar.xz`, - shasum: "aaa", + shasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", size: "12", }, "aarch64-windows": { tarball: `${env.R2_PUBLIC_URL}/zls-windows-aarch64-0.11.0.zip`, - shasum: "ccc", + shasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", size: "12", }, }, @@ -273,12 +280,14 @@ describe("/v1/zls/index.json", () => { date: "1970-01-01", "x86_64-linux": { tarball: `${env.R2_PUBLIC_URL}/zls-linux-x86_64-0.11.0.tar.xz`, - shasum: "aaa", + shasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", size: "12", }, "aarch64-windows": { tarball: `${env.R2_PUBLIC_URL}/zls-windows-aarch64-0.11.0.zip`, - shasum: "ccc", + shasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", size: "12", }, }, @@ -286,12 +295,14 @@ describe("/v1/zls/index.json", () => { date: "1970-01-01", "x86_64-linux": { tarball: `${env.R2_PUBLIC_URL}/zls-linux-x86_64-0.11.0.tar.xz`, - shasum: "aaa", + shasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", size: "12", }, "aarch64-windows": { tarball: `${env.R2_PUBLIC_URL}/zls-windows-aarch64-0.11.0.zip`, - shasum: "ccc", + shasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", size: "12", }, }, @@ -417,12 +428,14 @@ describe("/v1/zls/select-version", () => { version: "0.11.0", "x86_64-linux": { tarball: `${env.R2_PUBLIC_URL}/zls-linux-x86_64-0.11.0.tar.xz`, - shasum: "aaa", + shasum: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", size: "12", }, "aarch64-windows": { tarball: `${env.R2_PUBLIC_URL}/zls-windows-aarch64-0.11.0.zip`, - shasum: "ccc", + shasum: + "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", size: "12", }, });