Files
llmwiki-cli/test/storage.test.ts
doum1004 428e3e516e Refactor wiki structure and improve command functionality
- Renamed sections in the wiki index from Entities/Sources/Concepts to a more structured format.
- Removed the log.md file and its associated tests to streamline the logging process.
- Updated the ai-agent-patterns.md to include JSON write examples and demo conventions.
- Modified commands tests to handle JSON input for writing and reading pages.
- Implemented delete functionality for pages and ensured proper index updates.
- Enhanced index management to support upserting entries and handling duplicates.
- Removed deprecated profile tests and log manager tests to clean up the codebase.
- Adjusted storage tests to reflect changes in file writing locations.
2026-04-30 23:31:06 -04:00

47 lines
1.5 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import { mkdtemp, rm, readFile } from "fs/promises";
import { join } from "path";
import { tmpdir } from "os";
import { createProvider } from "../src/lib/storage.ts";
import type { WikiConfig } from "../src/types.ts";
function makeConfig(): WikiConfig {
return {
name: "test",
domain: "general",
created: new Date().toISOString(),
paths: { raw: "raw", wiki: "wiki", schema: "SCHEMA.md" },
};
}
let testDir: string;
beforeEach(async () => {
testDir = await mkdtemp(join(tmpdir(), "llmwiki-storage-"));
});
afterEach(async () => {
await rm(testDir, { recursive: true, force: true });
});
describe("createProvider", () => {
it("creates a filesystem provider", async () => {
const provider = await createProvider(makeConfig(), testDir);
expect(provider).toBeDefined();
expect(provider.readPage).toBeInstanceOf(Function);
expect(provider.writePage).toBeInstanceOf(Function);
expect(provider.appendPage).toBeInstanceOf(Function);
expect(provider.deletePage).toBeInstanceOf(Function);
expect(provider.pageExists).toBeInstanceOf(Function);
expect(provider.listPages).toBeInstanceOf(Function);
});
it("filesystem provider writes under wiki root", async () => {
const provider = await createProvider(makeConfig(), testDir);
await provider.writePage("wiki/note.md", "scoped");
const full = join(testDir, "wiki", "note.md");
const content = await readFile(full, "utf-8");
expect(content).toBe("scoped");
});
});