mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-25 23:47:20 +00:00
test: strengthen regression coverage and trim low-value checks
This commit is contained in:
@@ -14,13 +14,20 @@ function mockProcReads(entries: Record<string, string>) {
|
||||
}
|
||||
|
||||
async function withLinuxProcessPlatform<T>(run: () => Promise<T>): Promise<T> {
|
||||
return withProcessPlatform("linux", run);
|
||||
}
|
||||
|
||||
async function withProcessPlatform<T>(
|
||||
platform: NodeJS.Platform,
|
||||
run: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");
|
||||
if (!originalPlatformDescriptor) {
|
||||
throw new Error("missing process.platform descriptor");
|
||||
}
|
||||
Object.defineProperty(process, "platform", {
|
||||
...originalPlatformDescriptor,
|
||||
value: "linux",
|
||||
value: platform,
|
||||
});
|
||||
try {
|
||||
vi.resetModules();
|
||||
@@ -102,12 +109,10 @@ describe("getProcessStartTime", () => {
|
||||
});
|
||||
|
||||
it("returns null on non-Linux platforms", () => {
|
||||
if (process.platform === "linux") {
|
||||
// On actual Linux, this test is trivially satisfied by the other tests.
|
||||
expect(true).toBe(true);
|
||||
return;
|
||||
}
|
||||
expect(getProcessStartTime(process.pid)).toBeNull();
|
||||
return withProcessPlatform("darwin", async () => {
|
||||
const { getProcessStartTime: fresh } = await import("./pid-alive.js");
|
||||
expect(fresh(process.pid)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null for invalid PIDs", () => {
|
||||
|
||||
Reference in New Issue
Block a user