fix: test

This commit is contained in:
LukeGus committed 2026-11-05 12:52:04 -06:00
1 parent 041e10eb5c
commit c09d09f2ce
2 files changed
+34 -8

No files matched your search

+22 -1
View File
@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import crypto from "node:crypto";
import fs from "node:fs";
import os from "node:os";
@@ -471,6 +471,27 @@ describe("rebuilding local plugins", () => {
expect(isLocalBuildStale(root)).toBe(false);
});
it("survives a build replacing dist during the scan", () => {
const root = repo(tempDir(), "Plugin-A", "a");
const gone = path.join(root, "dist", "migrations", "postgres");
fs.mkdirSync(gone, { recursive: true });
fs.writeFileSync(path.join(root, "manifest.json"), "{}");
const realStat = fs.statSync;
const spy = vi.spyOn(fs, "statSync").mockImplementation(((
target: string,
) => {
if (target === gone) {
throw Object.assign(new Error("gone"), { code: "ENOENT" });
}
return realStat(target);
}) as typeof fs.statSync);
try {
expect(() => isLocalBuildStale(root)).not.toThrow();
} finally {
spy.mockRestore();
}
});
it("builds with this checkout's SDK CLI, not the plugin's own", () => {
const [command, args] = localSdkBuildCommand();
expect(command).toBe(process.execPath);