Isolate OpenCode test configuration from developer state

This commit is contained in:
Dotta 2026-09-11 15:19:32 -05:00
parent 47dfb0eb32
commit 85aaea820a
3 changed files with 31 additions and 3 deletions

View File

@ -104,12 +104,16 @@ describe("opencode remote execution", () => {
const cleanupDirs: string[] = [];
const originalOpenCodeAllowAllModels = process.env.OPENCODE_ALLOW_ALL_MODELS;
beforeEach(() => {
beforeEach(async () => {
const configHome = await mkdtemp(path.join(os.tmpdir(), "paperclip-opencode-test-config-"));
cleanupDirs.push(configHome);
vi.stubEnv("XDG_CONFIG_HOME", configHome);
delete process.env.OPENCODE_ALLOW_ALL_MODELS;
});
afterEach(async () => {
vi.clearAllMocks();
vi.unstubAllEnvs();
if (originalOpenCodeAllowAllModels === undefined) {
delete process.env.OPENCODE_ALLOW_ALL_MODELS;
} else {

View File

@ -34,6 +34,18 @@ function probeResult(overrides: Record<string, unknown>) {
}
describe("OpenCode local skill injection", () => {
let configHome: string;
beforeEach(async () => {
configHome = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-opencode-test-config-"));
vi.stubEnv("XDG_CONFIG_HOME", configHome);
});
afterEach(async () => {
vi.unstubAllEnvs();
await fs.rm(configHome, { recursive: true, force: true });
});
it("injects runtime skills into the configured child HOME", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "paperclip-opencode-configured-home-"));
const processHome = path.join(root, "process-home");

View File

@ -1,4 +1,7 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { mkdtemp, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { AdapterExecutionTarget } from "@paperclipai/adapter-utils/execution-target";
const {
@ -71,8 +74,17 @@ vi.mock("@paperclipai/adapter-utils/execution-target", async () => {
import { testEnvironment } from "./test.js";
describe("opencode remote environment diagnostics", () => {
afterEach(() => {
let configHome: string;
beforeEach(async () => {
configHome = await mkdtemp(path.join(os.tmpdir(), "paperclip-opencode-test-config-"));
vi.stubEnv("XDG_CONFIG_HOME", configHome);
});
afterEach(async () => {
vi.clearAllMocks();
vi.unstubAllEnvs();
await rm(configHome, { recursive: true, force: true });
});
it("stages remote runtime config assets for sandbox hello probes", async () => {