setup-uv/__tests__/download/checksum/checksum.test.ts

38 lines
893 B
TypeScript
Raw Normal View History

import { expect, test, it } from "@jest/globals";
2024-08-24 05:58:26 +08:00
import {
isknownVersion,
validateChecksum,
} from "../../../src/download/checksum/checksum";
2024-08-24 05:58:26 +08:00
test("checksum should match", async () => {
2024-08-24 05:58:26 +08:00
const validChecksum =
"f3da96ec7e995debee7f5d52ecd034dfb7074309a1da42f76429ecb814d813a3";
const filePath = "__tests__/fixtures/checksumfile";
2024-08-24 05:58:26 +08:00
// string params don't matter only test the checksum mechanism, not known checksums
await validateChecksum(
validChecksum,
filePath,
"aarch64",
"pc-windows-msvc",
"1.2.3",
);
});
2024-08-24 05:58:26 +08:00
type KnownVersionFixture = { version: string; known: boolean };
2024-08-24 05:58:26 +08:00
it.each<KnownVersionFixture>([
{
version: "0.3.0",
known: true,
2024-08-24 05:58:26 +08:00
},
{
version: "0.0.15",
known: false,
},
2024-08-24 05:58:26 +08:00
])(
"isknownVersion should return $known for version $version",
({ version, known }) => {
expect(isknownVersion(version)).toBe(known);
},
);