1
0

fix: 修复 Windows 平台测试兼容性问题

- 新增 tests/helpers.ts 的 rmRetry 工具函数,解决 SQLite 文件句柄未及时释放导致 afterAll 清理时 EBUSY 错误
- 修改通配符测试用例,使用 bun -e 替代 echo 命令,确保跨平台行为一致
This commit is contained in:
2026-05-12 22:11:34 +08:00
parent ad87be6956
commit 87d946a441
6 changed files with 47 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import { mkdir, rm } from "node:fs/promises";
import { mkdir } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -10,6 +10,7 @@ import { checkerRegistry } from "../../src/server/checker/runner";
import { CommandChecker } from "../../src/server/checker/runner/command/runner";
import { HttpChecker } from "../../src/server/checker/runner/http/runner";
import { ProbeStore } from "../../src/server/checker/store";
import { rmRetry } from "../helpers";
function ensureRegistered() {
if (!checkerRegistry.supportedTypes.includes("http")) {
@@ -100,7 +101,7 @@ describe("API 路由", () => {
afterAll(async () => {
store.close();
await rm(tempDir, { force: true, recursive: true });
await rmRetry(tempDir);
});
test("/health 返回健康检查", async () => {