Skip to content

Commit f3b5718

Browse files
committed
test(commands): isolate doctor gateway token environment
1 parent f212a42 commit f3b5718

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/commands/doctor-gateway-services.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ import { EXTERNAL_SERVICE_REPAIR_NOTE } from "./doctor-service-repair-policy.js"
153153

154154
const originalStdinIsTTY = process.stdin.isTTY;
155155
const originalPlatform = process.platform;
156+
const originalGatewayToken = process.env.OPENCLAW_GATEWAY_TOKEN;
156157
const originalUpdateInProgress = process.env.OPENCLAW_UPDATE_IN_PROGRESS;
157158
const originalParentSupportsConfigWrite =
158159
process.env.OPENCLAW_UPDATE_PARENT_SUPPORTS_DOCTOR_CONFIG_WRITE;
@@ -433,6 +434,7 @@ function setupGatewayTokenRepairScenario() {
433434
describe("maybeRepairGatewayServiceConfig", () => {
434435
beforeEach(() => {
435436
vi.clearAllMocks();
437+
delete process.env.OPENCLAW_GATEWAY_TOKEN;
436438
fsMocks.realpath.mockImplementation(async (value: string) => value);
437439
mocks.resolveGatewayPort.mockReturnValue(18789);
438440
mocks.isDefaultInstallIdentity.mockReturnValue(true);
@@ -457,6 +459,11 @@ describe("maybeRepairGatewayServiceConfig", () => {
457459
configurable: true,
458460
});
459461
mockProcessPlatform(originalPlatform);
462+
if (originalGatewayToken === undefined) {
463+
delete process.env.OPENCLAW_GATEWAY_TOKEN;
464+
} else {
465+
process.env.OPENCLAW_GATEWAY_TOKEN = originalGatewayToken;
466+
}
460467
if (originalUpdateInProgress === undefined) {
461468
delete process.env.OPENCLAW_UPDATE_IN_PROGRESS;
462469
} else {

0 commit comments

Comments
 (0)