test: add unit tests for getArchitecture and getAvx2 Windows ARM64 fallback logic (#153)
* Initial plan * Add unit tests for getArchitecture function Co-authored-by: xhyrom <56601352+xhyrom@users.noreply.github.com> * Remove unused import in utils.spec.ts Co-authored-by: xhyrom <56601352+xhyrom@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Merge pr-131 and resolve test file conflicts Co-authored-by: xhyrom <56601352+xhyrom@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: xhyrom <56601352+xhyrom@users.noreply.github.com> Co-authored-by: Jozef Steinhübl <generalkubo@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a9fae19735
commit
07891155a2
@ -1,5 +1,80 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { getAvx2 } from "../src/utils";
|
||||
import { afterEach, describe, expect, it, spyOn } from "bun:test";
|
||||
import { getArchitecture, getAvx2 } from "../src/utils";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
describe("getArchitecture", () => {
|
||||
let warningSpy: ReturnType<typeof spyOn>;
|
||||
|
||||
afterEach(() => {
|
||||
warningSpy?.mockRestore();
|
||||
});
|
||||
|
||||
it("should return x64 for Windows with arm64 architecture", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "arm64");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return x64 for Windows with aarch64 architecture", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "aarch64");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warningSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"⚠️ Bun does not provide native arm64 builds for Windows."
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should return aarch64 for non-Windows platforms with arm64", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("linux", "arm64");
|
||||
|
||||
expect(result).toBe("aarch64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return aarch64 for macOS with arm64", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("darwin", "arm64");
|
||||
|
||||
expect(result).toBe("aarch64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return original arch value for x64", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("windows", "x64");
|
||||
|
||||
expect(result).toBe("x64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return original arch value for x86", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("linux", "x86");
|
||||
|
||||
expect(result).toBe("x86");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should return original arch value for aarch64 on Linux", () => {
|
||||
warningSpy = spyOn(core, "warning");
|
||||
const result = getArchitecture("linux", "aarch64");
|
||||
|
||||
expect(result).toBe("aarch64");
|
||||
expect(warningSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAvx2", () => {
|
||||
it("should return false when called with os: 'windows' and arch: 'arm64'", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user