test: stabilize gateway mock + lint
This commit is contained in:
@@ -137,16 +137,18 @@ async function* fakeOpenAIResponsesStream(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
vi.mock("openai", () => {
|
function installOpenAIMock() {
|
||||||
class OpenAI {
|
vi.doMock("openai", () => {
|
||||||
responses = {
|
class OpenAI {
|
||||||
create: async (params: OpenAIResponsesParams) =>
|
responses = {
|
||||||
fakeOpenAIResponsesStream(params),
|
create: async (params: OpenAIResponsesParams) =>
|
||||||
};
|
fakeOpenAIResponsesStream(params),
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return { default: OpenAI };
|
return { default: OpenAI };
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function getFreePort(): Promise<number> {
|
async function getFreePort(): Promise<number> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
@@ -244,6 +246,9 @@ async function connectClient(params: { url: string; token: string }) {
|
|||||||
|
|
||||||
describe("gateway (mock openai): tool calling", () => {
|
describe("gateway (mock openai): tool calling", () => {
|
||||||
it("runs a Read tool call end-to-end via gateway agent loop", async () => {
|
it("runs a Read tool call end-to-end via gateway agent loop", async () => {
|
||||||
|
vi.resetModules();
|
||||||
|
installOpenAIMock();
|
||||||
|
|
||||||
const prev = {
|
const prev = {
|
||||||
home: process.env.HOME,
|
home: process.env.HOME,
|
||||||
configPath: process.env.CLAWDBOT_CONFIG_PATH,
|
configPath: process.env.CLAWDBOT_CONFIG_PATH,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import {
|
|||||||
import { danger, logVerbose, shouldLogVerbose } from "../globals.js";
|
import { danger, logVerbose, shouldLogVerbose } from "../globals.js";
|
||||||
import { enqueueSystemEvent } from "../infra/system-events.js";
|
import { enqueueSystemEvent } from "../infra/system-events.js";
|
||||||
import { getChildLogger } from "../logging.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 { saveMediaBuffer } from "../media/store.js";
|
||||||
import { buildPairingReply } from "../pairing/pairing-messages.js";
|
import { buildPairingReply } from "../pairing/pairing-messages.js";
|
||||||
import {
|
import {
|
||||||
|
|||||||
Reference in New Issue
Block a user