refactor(test): temp home env + normalize status

This commit is contained in:
Peter Steinberger
2026-01-09 16:49:01 +01:00
parent e8d75a39bc
commit 8341b662af
7 changed files with 190 additions and 132 deletions

View File

@@ -29,23 +29,16 @@ function makeResult(text: string) {
async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
return withTempHomeBase(
async (home) => {
const previousBundledSkills = process.env.CLAWDBOT_BUNDLED_SKILLS_DIR;
process.env.CLAWDBOT_BUNDLED_SKILLS_DIR = path.join(
home,
"bundled-skills",
);
try {
vi.mocked(runEmbeddedPiAgent).mockReset();
return await fn(home);
} finally {
if (previousBundledSkills === undefined) {
delete process.env.CLAWDBOT_BUNDLED_SKILLS_DIR;
} else {
process.env.CLAWDBOT_BUNDLED_SKILLS_DIR = previousBundledSkills;
}
}
vi.mocked(runEmbeddedPiAgent).mockReset();
return await fn(home);
},
{
env: {
CLAWDBOT_BUNDLED_SKILLS_DIR: (home) =>
path.join(home, "bundled-skills"),
},
prefix: "clawdbot-media-note-",
},
{ prefix: "clawdbot-media-note-" },
);
}