mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-04 11:01:16 +01:00
Improve runtime and import reliability
This commit is contained in:
1 parent
c91a062326
commit
114181e374
10 files changed
+486
-19
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { ensureLinuxSharedLibraryAliases } from "./embedded-postgres-native.js";
|
||||
|
||||
describe("embedded Postgres native runtime", () => {
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const tempDir of tempDirs.splice(0)) {
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")("creates soname aliases for bundled patch-level shared libraries", async () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-embedded-pg-libs-"));
|
||||
tempDirs.push(tempDir);
|
||||
fs.writeFileSync(path.join(tempDir, "libicuuc.so.60.2"), "");
|
||||
fs.writeFileSync(path.join(tempDir, "libicui18n.so.60.2"), "");
|
||||
fs.writeFileSync(path.join(tempDir, "README.md"), "");
|
||||
|
||||
const created = await ensureLinuxSharedLibraryAliases(tempDir);
|
||||
|
||||
expect(created.map((file) => path.basename(file)).sort()).toEqual([
|
||||
"libicui18n.so.60",
|
||||
"libicuuc.so.60",
|
||||
]);
|
||||
expect(fs.readlinkSync(path.join(tempDir, "libicuuc.so.60"))).toBe("libicuuc.so.60.2");
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")("is idempotent when aliases already exist", async () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-embedded-pg-libs-"));
|
||||
tempDirs.push(tempDir);
|
||||
fs.writeFileSync(path.join(tempDir, "libicuuc.so.60.2"), "");
|
||||
|
||||
await ensureLinuxSharedLibraryAliases(tempDir);
|
||||
const second = await ensureLinuxSharedLibraryAliases(tempDir);
|
||||
|
||||
expect(second).toEqual([]);
|
||||
expect(fs.readlinkSync(path.join(tempDir, "libicuuc.so.60"))).toBe("libicuuc.so.60.2");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user