remoteDetectEnv.test.ts 1019 B

12345678910111213141516171819202122232425262728293031
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. normalizeRemoteArch,
  4. normalizeRemotePlatform,
  5. resolveRemotePlatform,
  6. } from "../src/remote/detectEnv.js";
  7. describe("remote detect env", () => {
  8. it("x86_64 / amd64 应归一化为 x64", () => {
  9. expect(normalizeRemoteArch("x86_64")).toBe("x64");
  10. expect(normalizeRemoteArch("amd64")).toBe("x64");
  11. });
  12. it("aarch64 / arm64e 应归一化为 arm64", () => {
  13. expect(normalizeRemoteArch("aarch64")).toBe("arm64");
  14. expect(normalizeRemoteArch("arm64e")).toBe("arm64");
  15. });
  16. it("darwin + linux 内核探针时应回退到 linux", () => {
  17. expect(resolveRemotePlatform("darwin", "linux")).toBe("linux");
  18. });
  19. it("真实 darwin 场景(无 /proc 内核值)不应回退", () => {
  20. expect(resolveRemotePlatform("darwin", "")).toBe("darwin");
  21. });
  22. it("platform 别名应归一化", () => {
  23. expect(normalizeRemotePlatform("GNU/Linux")).toBe("linux");
  24. expect(normalizeRemotePlatform("Windows_NT")).toBe("win32");
  25. });
  26. });