@@ -3,7 +3,8 @@ import { createHash } from "node:crypto";
33import fs from "node:fs/promises" ;
44import os from "node:os" ;
55import path from "node:path" ;
6- import { beforeEach , describe , expect , it , vi } from "vitest" ;
6+ import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
7+ import { createTrackedTempDirs } from "../../test-utils/tracked-temp-dirs.js" ;
78
89const fetchClawHubSkillDetailMock = vi . fn ( ) ;
910const fetchClawHubSkillInstallResolutionMock = vi . fn ( ) ;
@@ -21,6 +22,7 @@ const withExtractedArchiveRootMock = vi.fn();
2122const installPackageDirMock = vi . fn ( ) ;
2223const evaluateSkillInstallPolicyMock = vi . fn ( ) ;
2324const pathExistsMock = vi . fn ( ) ;
25+ const tempDirs = createTrackedTempDirs ( ) ;
2426
2527vi . mock ( "../../infra/clawhub.js" , ( ) => ( {
2628 fetchClawHubSkillDetail : fetchClawHubSkillDetailMock ,
@@ -165,6 +167,10 @@ async function writeClawHubOriginFixture(params: {
165167}
166168
167169describe ( "skills-clawhub" , ( ) => {
170+ afterEach ( async ( ) => {
171+ await tempDirs . cleanup ( ) ;
172+ } ) ;
173+
168174 beforeEach ( ( ) => {
169175 fetchClawHubSkillDetailMock . mockReset ( ) ;
170176 fetchClawHubSkillInstallResolutionMock . mockReset ( ) ;
@@ -302,7 +308,7 @@ describe("skills-clawhub", () => {
302308 } ) ;
303309
304310 it ( "persists install artifact and verification provenance in the ClawHub lockfile" , async ( ) => {
305- const workspaceDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-skills-lock-" ) ) ;
311+ const workspaceDir = await tempDirs . make ( "openclaw-skills-lock-" ) ;
306312 const skillContent = "---\nname: agentreceipt\ndescription: Receipt helper\n---\n" ;
307313 const skillSha256 = createHash ( "sha256" ) . update ( skillContent ) . digest ( "hex" ) ;
308314 installPackageDirMock . mockImplementationOnce ( async ( params : { targetDir : string } ) => {
@@ -377,7 +383,7 @@ describe("skills-clawhub", () => {
377383 } ) ;
378384
379385 it ( "keeps installing when the ClawHub verification snapshot is unavailable" , async ( ) => {
380- const workspaceDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-skills-lock-" ) ) ;
386+ const workspaceDir = await tempDirs . make ( "openclaw-skills-lock-" ) ;
381387 fetchClawHubSkillVerificationMock . mockRejectedValueOnce ( new Error ( "verification down" ) ) ;
382388 installPackageDirMock . mockImplementationOnce ( async ( params : { targetDir : string } ) => {
383389 await fs . mkdir ( params . targetDir , { recursive : true } ) ;
0 commit comments