mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 09:02:02 +03:00
Tests: restore TUI gateway env
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
const loadConfig = vi.fn();
|
const loadConfig = vi.fn();
|
||||||
const resolveGatewayPort = vi.fn();
|
const resolveGatewayPort = vi.fn();
|
||||||
|
|
||||||
|
const originalEnvToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||||
|
const originalEnvPassword = process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||||
|
|
||||||
vi.mock("../config/config.js", async (importOriginal) => {
|
vi.mock("../config/config.js", async (importOriginal) => {
|
||||||
const actual = await importOriginal<typeof import("../config/config.js")>();
|
const actual = await importOriginal<typeof import("../config/config.js")>();
|
||||||
return {
|
return {
|
||||||
@@ -19,6 +22,22 @@ describe("resolveGatewayConnection", () => {
|
|||||||
loadConfig.mockReset();
|
loadConfig.mockReset();
|
||||||
resolveGatewayPort.mockReset();
|
resolveGatewayPort.mockReset();
|
||||||
resolveGatewayPort.mockReturnValue(18789);
|
resolveGatewayPort.mockReturnValue(18789);
|
||||||
|
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||||
|
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (originalEnvToken === undefined) {
|
||||||
|
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||||
|
} else {
|
||||||
|
process.env.OPENCLAW_GATEWAY_TOKEN = originalEnvToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originalEnvPassword === undefined) {
|
||||||
|
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||||
|
} else {
|
||||||
|
process.env.OPENCLAW_GATEWAY_PASSWORD = originalEnvPassword;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws when url override is missing explicit credentials", () => {
|
it("throws when url override is missing explicit credentials", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user