Skip to content

Commit c684d4e

Browse files
author
kjgbot
committed
test: avoid install-skill race pattern
1 parent b1c47c9 commit c684d4e

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/cli/lib/install-skill.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ describe('installSkill', () => {
3737
expect(dirStat.isDirectory()).toBe(true);
3838
expect(dirStat.mode & 0o777).toBe(0o755);
3939

40-
const fileStat = await fs.stat(result.destPath);
41-
expect(fileStat.mode & 0o777).toBe(0o644);
42-
43-
const written = await fs.readFile(result.destPath, 'utf-8');
44-
expect(written).toBe(SOURCE_BODY_V1);
40+
const handle = await fs.open(result.destPath, 'r');
41+
try {
42+
const fileStat = await handle.stat();
43+
expect(fileStat.mode & 0o777).toBe(0o644);
44+
45+
const written = await handle.readFile('utf-8');
46+
expect(written).toBe(SOURCE_BODY_V1);
47+
} finally {
48+
await handle.close();
49+
}
4550
} finally {
4651
process.umask(originalUmask);
4752
}

0 commit comments

Comments
 (0)