mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
test(agents): dedupe shared bootstrap and tool-id test setup
This commit is contained in:
@@ -9,23 +9,27 @@ import { makeTempWorkspace } from "../test-helpers/workspace.js";
|
||||
import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js";
|
||||
import type { WorkspaceBootstrapFile } from "./workspace.js";
|
||||
|
||||
function registerExtraBootstrapFileHook() {
|
||||
registerInternalHook("agent:bootstrap", (event) => {
|
||||
const context = event.context as AgentBootstrapHookContext;
|
||||
context.bootstrapFiles = [
|
||||
...context.bootstrapFiles,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
path: path.join(context.workspaceDir, "EXTRA.md"),
|
||||
content: "extra",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
describe("resolveBootstrapFilesForRun", () => {
|
||||
beforeEach(() => clearInternalHooks());
|
||||
afterEach(() => clearInternalHooks());
|
||||
|
||||
it("applies bootstrap hook overrides", async () => {
|
||||
registerInternalHook("agent:bootstrap", (event) => {
|
||||
const context = event.context as AgentBootstrapHookContext;
|
||||
context.bootstrapFiles = [
|
||||
...context.bootstrapFiles,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
path: path.join(context.workspaceDir, "EXTRA.md"),
|
||||
content: "extra",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
];
|
||||
});
|
||||
registerExtraBootstrapFileHook();
|
||||
|
||||
const workspaceDir = await makeTempWorkspace("openclaw-bootstrap-");
|
||||
const files = await resolveBootstrapFilesForRun({ workspaceDir });
|
||||
@@ -39,18 +43,7 @@ describe("resolveBootstrapContextForRun", () => {
|
||||
afterEach(() => clearInternalHooks());
|
||||
|
||||
it("returns context files for hook-adjusted bootstrap files", async () => {
|
||||
registerInternalHook("agent:bootstrap", (event) => {
|
||||
const context = event.context as AgentBootstrapHookContext;
|
||||
context.bootstrapFiles = [
|
||||
...context.bootstrapFiles,
|
||||
{
|
||||
name: "EXTRA.md",
|
||||
path: path.join(context.workspaceDir, "EXTRA.md"),
|
||||
content: "extra",
|
||||
missing: false,
|
||||
} as unknown as WorkspaceBootstrapFile,
|
||||
];
|
||||
});
|
||||
registerExtraBootstrapFileHook();
|
||||
|
||||
const workspaceDir = await makeTempWorkspace("openclaw-bootstrap-");
|
||||
const result = await resolveBootstrapContextForRun({ workspaceDir });
|
||||
|
||||
Reference in New Issue
Block a user