mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import fs from "node:fs/promises";
|
||
|
|
import os from "node:os";
|
||
|
|
import path from "node:path";
|
||
|
|
import { testEnvironment } from "@paperclipai/adapter-opencode-local/server";
|
||
|
|
|
||
|
|
describe("opencode_local environment diagnostics", () => {
|
||
|
|
it("creates a missing working directory when cwd is absolute", async () => {
|
||
|
|
const cwd = path.join(
|
||
|
|
os.tmpdir(),
|
||
|
|
`paperclip-opencode-local-cwd-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
||
|
|
"workspace",
|
||
|
|
);
|
||
|
|
|
||
|
|
await fs.rm(path.dirname(cwd), { recursive: true, force: true });
|
||
|
|
|
||
|
|
const result = await testEnvironment({
|
||
|
|
companyId: "company-1",
|
||
|
|
adapterType: "opencode_local",
|
||
|
|
config: {
|
||
|
|
command: process.execPath,
|
||
|
|
cwd,
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(result.checks.some((check) => check.code === "opencode_cwd_valid")).toBe(true);
|
||
|
|
expect(result.checks.some((check) => check.level === "error")).toBe(false);
|
||
|
|
const stats = await fs.stat(cwd);
|
||
|
|
expect(stats.isDirectory()).toBe(true);
|
||
|
|
await fs.rm(path.dirname(cwd), { recursive: true, force: true });
|
||
|
|
});
|
||
|
|
});
|