mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 12:00:44 +00:00
fix(update): use service env for doctor
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
resolveGatewayInstallEntrypoint,
|
||||
} from "../../daemon/gateway-entrypoint.js";
|
||||
import {
|
||||
resolvePostInstallDoctorEnv,
|
||||
shouldPrepareUpdatedInstallRestart,
|
||||
resolveUpdatedGatewayRestartPort,
|
||||
shouldUseLegacyProcessRestartAfterUpdate,
|
||||
@@ -106,6 +107,48 @@ describe("resolveUpdatedGatewayRestartPort", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolvePostInstallDoctorEnv", () => {
|
||||
it("uses the managed service profile paths for post-install doctor", () => {
|
||||
const env = resolvePostInstallDoctorEnv({
|
||||
invocationCwd: "/srv/openclaw",
|
||||
baseEnv: {
|
||||
PATH: "/bin",
|
||||
OPENCLAW_STATE_DIR: "/wrong/state",
|
||||
OPENCLAW_CONFIG_PATH: "/wrong/openclaw.json",
|
||||
OPENCLAW_PROFILE: "wrong",
|
||||
},
|
||||
serviceEnv: {
|
||||
OPENCLAW_STATE_DIR: "daemon-state",
|
||||
OPENCLAW_CONFIG_PATH: "daemon-state/openclaw.json",
|
||||
OPENCLAW_PROFILE: "work",
|
||||
},
|
||||
});
|
||||
|
||||
expect(env.PATH).toBe("/bin");
|
||||
expect(env.NODE_DISABLE_COMPILE_CACHE).toBe("1");
|
||||
expect(env.OPENCLAW_STATE_DIR).toBe(path.join("/srv/openclaw", "daemon-state"));
|
||||
expect(env.OPENCLAW_CONFIG_PATH).toBe(
|
||||
path.join("/srv/openclaw", "daemon-state", "openclaw.json"),
|
||||
);
|
||||
expect(env.OPENCLAW_PROFILE).toBe("work");
|
||||
});
|
||||
|
||||
it("keeps the caller env when no managed service env is available", () => {
|
||||
const env = resolvePostInstallDoctorEnv({
|
||||
baseEnv: {
|
||||
PATH: "/bin",
|
||||
OPENCLAW_STATE_DIR: "/caller/state",
|
||||
OPENCLAW_PROFILE: "caller",
|
||||
},
|
||||
});
|
||||
|
||||
expect(env.PATH).toBe("/bin");
|
||||
expect(env.NODE_DISABLE_COMPILE_CACHE).toBe("1");
|
||||
expect(env.OPENCLAW_STATE_DIR).toBe("/caller/state");
|
||||
expect(env.OPENCLAW_PROFILE).toBe("caller");
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldUseLegacyProcessRestartAfterUpdate", () => {
|
||||
it("never restarts package updates through the pre-update process", () => {
|
||||
expect(shouldUseLegacyProcessRestartAfterUpdate({ updateMode: "npm" })).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user