Tests: restore TUI gateway env
parent
a13ff55bd9
commit
5e025c4ba3
|
|
@ -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", () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue