mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:34:32 +00:00
refactor(test): simplify voicewake env cleanup
This commit is contained in:
@@ -10,6 +10,7 @@ import { resolveCanvasHostUrl } from "../infra/canvas-host-url.js";
|
|||||||
import { GatewayLockError } from "../infra/gateway-lock.js";
|
import { GatewayLockError } from "../infra/gateway-lock.js";
|
||||||
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
|
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
|
||||||
import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js";
|
import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js";
|
||||||
|
import { captureEnv } from "../test-utils/env.js";
|
||||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||||
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
||||||
import {
|
import {
|
||||||
@@ -301,31 +302,24 @@ describe("gateway server models + voicewake", () => {
|
|||||||
|
|
||||||
describe("gateway server misc", () => {
|
describe("gateway server misc", () => {
|
||||||
test("hello-ok advertises the gateway port for canvas host", async () => {
|
test("hello-ok advertises the gateway port for canvas host", async () => {
|
||||||
const prevToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
const envSnapshot = captureEnv(["OPENCLAW_CANVAS_HOST_PORT", "OPENCLAW_GATEWAY_TOKEN"]);
|
||||||
const prevCanvasPort = process.env.OPENCLAW_CANVAS_HOST_PORT;
|
try {
|
||||||
process.env.OPENCLAW_GATEWAY_TOKEN = "secret";
|
process.env.OPENCLAW_GATEWAY_TOKEN = "secret";
|
||||||
testTailnetIPv4.value = "100.64.0.1";
|
testTailnetIPv4.value = "100.64.0.1";
|
||||||
testState.gatewayBind = "lan";
|
testState.gatewayBind = "lan";
|
||||||
const canvasPort = await getFreePort();
|
const canvasPort = await getFreePort();
|
||||||
testState.canvasHostPort = canvasPort;
|
testState.canvasHostPort = canvasPort;
|
||||||
process.env.OPENCLAW_CANVAS_HOST_PORT = String(canvasPort);
|
process.env.OPENCLAW_CANVAS_HOST_PORT = String(canvasPort);
|
||||||
|
|
||||||
const testPort = await getFreePort();
|
const testPort = await getFreePort();
|
||||||
const canvasHostUrl = resolveCanvasHostUrl({
|
const canvasHostUrl = resolveCanvasHostUrl({
|
||||||
canvasPort,
|
canvasPort,
|
||||||
requestHost: `100.64.0.1:${testPort}`,
|
requestHost: `100.64.0.1:${testPort}`,
|
||||||
localAddress: "127.0.0.1",
|
localAddress: "127.0.0.1",
|
||||||
});
|
});
|
||||||
expect(canvasHostUrl).toBe(`http://100.64.0.1:${canvasPort}`);
|
expect(canvasHostUrl).toBe(`http://100.64.0.1:${canvasPort}`);
|
||||||
if (prevToken === undefined) {
|
} finally {
|
||||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
envSnapshot.restore();
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_GATEWAY_TOKEN = prevToken;
|
|
||||||
}
|
|
||||||
if (prevCanvasPort === undefined) {
|
|
||||||
delete process.env.OPENCLAW_CANVAS_HOST_PORT;
|
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_CANVAS_HOST_PORT = prevCanvasPort;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user