test: stabilize gateway mock + lint

This commit is contained in:
Peter Steinberger
2026-01-10 03:14:13 +00:00
parent 7376d1e6c9
commit 4f79122068
2 changed files with 15 additions and 10 deletions

View File

@@ -137,16 +137,18 @@ async function* fakeOpenAIResponsesStream(
};
}
vi.mock("openai", () => {
class OpenAI {
responses = {
create: async (params: OpenAIResponsesParams) =>
fakeOpenAIResponsesStream(params),
};
}
function installOpenAIMock() {
vi.doMock("openai", () => {
class OpenAI {
responses = {
create: async (params: OpenAIResponsesParams) =>
fakeOpenAIResponsesStream(params),
};
}
return { default: OpenAI };
});
return { default: OpenAI };
});
}
async function getFreePort(): Promise<number> {
return await new Promise((resolve, reject) => {
@@ -244,6 +246,9 @@ async function connectClient(params: { url: string; token: string }) {
describe("gateway (mock openai): tool calling", () => {
it("runs a Read tool call end-to-end via gateway agent loop", async () => {
vi.resetModules();
installOpenAIMock();
const prev = {
home: process.env.HOME,
configPath: process.env.CLAWDBOT_CONFIG_PATH,

View File

@@ -45,7 +45,7 @@ import {
import { danger, logVerbose, shouldLogVerbose } from "../globals.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
import { getChildLogger } from "../logging.js";
import { fetchRemoteMedia, type FetchLike } from "../media/fetch.js";
import { type FetchLike, fetchRemoteMedia } from "../media/fetch.js";
import { saveMediaBuffer } from "../media/store.js";
import { buildPairingReply } from "../pairing/pairing-messages.js";
import {