|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
|
|
import { describe, test, expect, beforeAll, afterAll, beforeEach, afterEach, mock, spyOn } from "bun:test";
|
|
import { describe, test, expect, beforeAll, afterAll, beforeEach, afterEach, mock, spyOn } from "bun:test";
|
|
|
import { Database } from "bun:sqlite";
|
|
import { Database } from "bun:sqlite";
|
|
|
|
|
+import * as sqliteVec from "sqlite-vec";
|
|
|
import { unlink, mkdtemp, rmdir, writeFile } from "node:fs/promises";
|
|
import { unlink, mkdtemp, rmdir, writeFile } from "node:fs/promises";
|
|
|
import { tmpdir } from "node:os";
|
|
import { tmpdir } from "node:os";
|
|
|
import { join } from "node:path";
|
|
import { join } from "node:path";
|
|
@@ -15,6 +16,7 @@ import YAML from "yaml";
|
|
|
import { disposeDefaultLlamaCpp } from "./llm.js";
|
|
import { disposeDefaultLlamaCpp } from "./llm.js";
|
|
|
import {
|
|
import {
|
|
|
createStore,
|
|
createStore,
|
|
|
|
|
+ verifySqliteVecLoaded,
|
|
|
getDefaultDbPath,
|
|
getDefaultDbPath,
|
|
|
homedir,
|
|
homedir,
|
|
|
resolve,
|
|
resolve,
|
|
@@ -452,6 +454,25 @@ describe("Store Creation", () => {
|
|
|
await cleanupTestDb(store);
|
|
await cleanupTestDb(store);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ test("verifySqliteVecLoaded throws when sqlite-vec is not loaded", () => {
|
|
|
|
|
+ const db = new Database(":memory:");
|
|
|
|
|
+ try {
|
|
|
|
|
+ expect(() => verifySqliteVecLoaded(db)).toThrow("sqlite-vec extension is unavailable");
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ db.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test("verifySqliteVecLoaded succeeds when sqlite-vec is loaded", () => {
|
|
|
|
|
+ const db = new Database(":memory:");
|
|
|
|
|
+ try {
|
|
|
|
|
+ sqliteVec.load(db);
|
|
|
|
|
+ expect(() => verifySqliteVecLoaded(db)).not.toThrow();
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ db.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
test("store.close closes the database connection", async () => {
|
|
test("store.close closes the database connection", async () => {
|
|
|
const store = await createTestStore();
|
|
const store = await createTestStore();
|
|
|
store.close();
|
|
store.close();
|