



















@@ -127,13 +127,11 @@ describe("buildGatewayInstallPlan", () => {
127127expect(plan.workingDirectory).toBe("/Users/me");
128128expect(plan.environment).toEqual({ OPENCLAW_PORT: "3000" });
129129expect(mocks.resolvePreferredNodePath).not.toHaveBeenCalled();
130-expect(mocks.buildServiceEnvironment).toHaveBeenCalledWith(
131-expect.objectContaining({
132-env: { HOME: isolatedHome },
133-port: 3000,
134-extraPathDirs: ["/custom"],
135-}),
136-);
130+expect(mocks.buildServiceEnvironment).toHaveBeenCalledOnce();
131+const serviceEnvRequest = mocks.buildServiceEnvironment.mock.calls[0]?.[0];
132+expect(serviceEnvRequest?.env).toStrictEqual({ HOME: isolatedHome });
133+expect(serviceEnvRequest?.port).toBe(3000);
134+expect(serviceEnvRequest?.extraPathDirs).toStrictEqual(["/custom"]);
137135});
138136139137it("does not prepend '.' when nodePath is a bare executable name", async () => {
@@ -146,11 +144,8 @@ describe("buildGatewayInstallPlan", () => {
146144nodePath: "node",
147145});
148146149-expect(mocks.buildServiceEnvironment).toHaveBeenCalledWith(
150-expect.objectContaining({
151-extraPathDirs: undefined,
152-}),
153-);
147+expect(mocks.buildServiceEnvironment).toHaveBeenCalledOnce();
148+expect(mocks.buildServiceEnvironment.mock.calls[0]?.[0]?.extraPathDirs).toBeUndefined();
154149});
155150156151it("emits warnings when renderSystemNodeWarning returns one", async () => {
@@ -188,11 +183,8 @@ describe("buildGatewayInstallPlan", () => {
188183});
189184190185expect(plan.workingDirectory).toBe(path.join(isolatedHome, ".openclaw"));
191-expect(mocks.buildServiceEnvironment).toHaveBeenCalledWith(
192-expect.objectContaining({
193-platform: "darwin",
194-}),
195-);
186+expect(mocks.buildServiceEnvironment).toHaveBeenCalledOnce();
187+expect(mocks.buildServiceEnvironment.mock.calls[0]?.[0]?.platform).toBe("darwin");
196188});
197189198190it("does not invent a working directory for non-macOS service installs", async () => {
@@ -228,17 +220,11 @@ describe("buildGatewayInstallPlan", () => {
228220runtime: "node",
229221});
230222231-expect(mocks.resolveGatewayProgramArguments).toHaveBeenCalledWith(
232-expect.objectContaining({
233- wrapperPath,
234-}),
235-);
236-expect(mocks.buildServiceEnvironment).toHaveBeenCalledWith(
237-expect.objectContaining({
238-env: expect.objectContaining({
239-OPENCLAW_WRAPPER: wrapperPath,
240-}),
241-}),
223+expect(mocks.resolveGatewayProgramArguments).toHaveBeenCalledOnce();
224+expect(mocks.resolveGatewayProgramArguments.mock.calls[0]?.[0]?.wrapperPath).toBe(wrapperPath);
225+expect(mocks.buildServiceEnvironment).toHaveBeenCalledOnce();
226+expect(mocks.buildServiceEnvironment.mock.calls[0]?.[0]?.env?.OPENCLAW_WRAPPER).toBe(
227+wrapperPath,
242228);
243229expect(plan.environment.OPENCLAW_WRAPPER).toBe(wrapperPath);
244230});
@@ -409,25 +395,19 @@ describe("buildGatewayInstallPlan", () => {
409395'Exec SecretRef passEnv ref "HOME" blocked by host-env security policy',
410396"Config SecretRef",
411397);
412-expect(warn).toHaveBeenCalledWith(
413-expect.stringContaining("XDG_CONFIG_HOME"),
414-"Config SecretRef",
415-);
416-expect(warn).toHaveBeenCalledWith(
417-expect.stringContaining("XDG_CONFIG_DIRS"),
418-"Config SecretRef",
419-);
420-expect(warn).toHaveBeenCalledWith(expect.stringContaining("BASH_ENV"), "Config SecretRef");
421-expect(warn).toHaveBeenCalledWith(expect.stringContaining("GH_TOKEN"), "Config SecretRef");
422-expect(warn).toHaveBeenCalledWith(
423-expect.stringContaining("AWS_ACCESS_KEY_ID"),
424-"Config SecretRef",
425-);
426-expect(warn).toHaveBeenCalledWith(expect.stringContaining("DOCKER_HOST"), "Config SecretRef");
427-expect(warn).toHaveBeenCalledWith(
428-expect.stringContaining("NODE_TLS_REJECT_UNAUTHORIZED"),
429-"Config SecretRef",
430-);
398+const warningMessages = warn.mock.calls.map(([message]) => message);
399+for (const blockedName of [
400+"XDG_CONFIG_HOME",
401+"XDG_CONFIG_DIRS",
402+"BASH_ENV",
403+"GH_TOKEN",
404+"AWS_ACCESS_KEY_ID",
405+"DOCKER_HOST",
406+"NODE_TLS_REJECT_UNAUTHORIZED",
407+]) {
408+expect(warningMessages.some((message) => message.includes(blockedName))).toBe(true);
409+}
410+expect(warn.mock.calls.every(([, title]) => title === "Config SecretRef")).toBe(true);
431411});
432412433413it("does not include passEnv values for unused exec SecretRef providers", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。