mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-19 20:10:39 +09:00
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||
|
|
|
||
|
|
const { mockResolveEnvironmentDriverConfigForRuntime } = vi.hoisted(() => ({
|
||
|
|
mockResolveEnvironmentDriverConfigForRuntime: vi.fn(),
|
||
|
|
}));
|
||
|
|
|
||
|
|
vi.mock("../services/environment-config.js", () => ({
|
||
|
|
resolveEnvironmentDriverConfigForRuntime: mockResolveEnvironmentDriverConfigForRuntime,
|
||
|
|
}));
|
||
|
|
|
||
|
|
import {
|
||
|
|
DEFAULT_SANDBOX_REMOTE_CWD,
|
||
|
|
resolveEnvironmentExecutionTarget,
|
||
|
|
} from "../services/environment-execution-target.js";
|
||
|
|
|
||
|
|
describe("resolveEnvironmentExecutionTarget", () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
mockResolveEnvironmentDriverConfigForRuntime.mockReset();
|
||
|
|
});
|
||
|
|
|
||
|
|
it("uses a bounded default cwd for sandbox targets when lease metadata omits remoteCwd", async () => {
|
||
|
|
mockResolveEnvironmentDriverConfigForRuntime.mockResolvedValue({
|
||
|
|
driver: "sandbox",
|
||
|
|
config: {
|
||
|
|
provider: "fake-plugin",
|
||
|
|
reuseLease: false,
|
||
|
|
timeoutMs: 30_000,
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
const target = await resolveEnvironmentExecutionTarget({
|
||
|
|
db: {} as never,
|
||
|
|
companyId: "company-1",
|
||
|
|
adapterType: "codex_local",
|
||
|
|
environment: {
|
||
|
|
id: "env-1",
|
||
|
|
driver: "sandbox",
|
||
|
|
config: {
|
||
|
|
provider: "fake-plugin",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
leaseId: "lease-1",
|
||
|
|
leaseMetadata: {},
|
||
|
|
lease: null,
|
||
|
|
environmentRuntime: null,
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(target).toMatchObject({
|
||
|
|
kind: "remote",
|
||
|
|
transport: "sandbox",
|
||
|
|
providerKey: "fake-plugin",
|
||
|
|
remoteCwd: DEFAULT_SANDBOX_REMOTE_CWD,
|
||
|
|
leaseId: "lease-1",
|
||
|
|
environmentId: "env-1",
|
||
|
|
timeoutMs: 30_000,
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|