Skip to content

Commit 6edc751

Browse files
committed
test: add detectInstallationMethod stored-info path and getCurlInstallPaths branch tests
1 parent 6064cd6 commit 6edc751

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/lib/upgrade.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,52 @@ describe("executeUpgrade", () => {
596596
});
597597
});
598598

599+
describe("detectInstallationMethod — stored info path", () => {
600+
useTestConfigDir("test-detect-stored-");
601+
602+
let originalExecPath: string;
603+
604+
beforeEach(() => {
605+
originalExecPath = process.execPath;
606+
// Set execPath to a non-Homebrew, non-known-curl path so detection falls
607+
// through to stored info
608+
Object.defineProperty(process, "execPath", {
609+
value: "/usr/bin/sentry",
610+
configurable: true,
611+
});
612+
});
613+
614+
afterEach(() => {
615+
Object.defineProperty(process, "execPath", {
616+
value: originalExecPath,
617+
configurable: true,
618+
});
619+
clearInstallInfo();
620+
});
621+
622+
test("returns stored method when install info has been persisted", async () => {
623+
setInstallInfo({
624+
method: "npm",
625+
path: "/usr/bin/sentry",
626+
version: "1.0.0",
627+
});
628+
629+
const method = await detectInstallationMethod();
630+
expect(method).toBe("npm");
631+
});
632+
633+
test("returns stored curl method", async () => {
634+
setInstallInfo({
635+
method: "curl",
636+
path: "/usr/bin/sentry",
637+
version: "1.0.0",
638+
});
639+
640+
const method = await detectInstallationMethod();
641+
expect(method).toBe("curl");
642+
});
643+
});
644+
599645
describe("Homebrew detection (detectInstallationMethod)", () => {
600646
let originalExecPath: string;
601647

0 commit comments

Comments
 (0)