mirror of
https://github.com/oven-sh/setup-bun.git
synced 2026-05-20 15:20:14 +02:00
* fix: validate cached binary version matches requested version (#146) * fix: fail closed when cached version cannot be verified
This commit is contained in:
+21
-1
@@ -1,7 +1,27 @@
|
||||
import { afterEach, describe, expect, it, spyOn } from "bun:test";
|
||||
import { getArchitecture, getAvx2, hasNativeWindowsArm64 } from "../src/utils";
|
||||
import { extractVersionFromUrl, getArchitecture, getAvx2, hasNativeWindowsArm64 } from "../src/utils";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
describe("extractVersionFromUrl", () => {
|
||||
it("should extract version from standard download URL", () => {
|
||||
expect(extractVersionFromUrl("https://github.com/oven-sh/bun/releases/download/bun-v1.3.1/bun-linux-x64.zip")).toBe("1.3.1");
|
||||
expect(extractVersionFromUrl("https://github.com/oven-sh/bun/releases/download/bun-v1.0.0/bun-darwin-aarch64.zip")).toBe("1.0.0");
|
||||
expect(extractVersionFromUrl("https://github.com/oven-sh/bun/releases/download/bun-v0.5.0/bun-linux-x64-baseline.zip")).toBe("0.5.0");
|
||||
});
|
||||
|
||||
it("should extract version from URL with profile suffix", () => {
|
||||
expect(extractVersionFromUrl("https://github.com/oven-sh/bun/releases/download/bun-v1.1.0/bun-linux-x64-profile.zip")).toBe("1.1.0");
|
||||
});
|
||||
|
||||
it("should return undefined for canary URL", () => {
|
||||
expect(extractVersionFromUrl("https://github.com/oven-sh/bun/releases/download/canary/bun-linux-x64.zip")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return undefined for custom/non-standard URL", () => {
|
||||
expect(extractVersionFromUrl("https://example.com/bun.zip")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasNativeWindowsArm64", () => {
|
||||
it("should return true for version >= 1.3.10", () => {
|
||||
expect(hasNativeWindowsArm64("bun-v1.3.10")).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user