test: group computer environment selection with driver contracts

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-10 09:05:04 -05:00
1 parent 5cf8cbd761
commit 1c4d403044
2 files changed
+10 -11

No files matched your search

@@ -1,11 +0,0 @@
import { describe, expect, it } from "vitest";
import { assertEnvironmentSelectionForCompany } from "../services/environment-selection.js";
describe("computer environment selection", () => {
const environment = { id: "environment", driver: "computer", status: "active", config: {}, metadata: { computerCompanyId: "owner" } };
const service = { getById: async () => environment };
it("permits the attached company and rejects another company", async () => {
await expect(assertEnvironmentSelectionForCompany(service, "owner", "environment")).resolves.toBeUndefined();
await expect(assertEnvironmentSelectionForCompany(service, "other", "environment")).rejects.toThrow("not available in this company");
});
});
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from "vitest";
import { resolveEnvironmentExecutionTarget, resolveEnvironmentExecutionTransport } from "./environment-execution-target.js";
import { createComputerEnvironmentDriver } from "./computer-environment-driver.js";
import { assertEnvironmentSelectionForCompany } from "./environment-selection.js";
const state = vi.hoisted(() => {
const binding = { owner: { computerId: "computer", ownerId: "owner", generation: 1 },
@@ -44,3 +45,12 @@ describe("computer environment probe ownership", () => {
expect(state.acquireLease).toHaveBeenCalledWith(expect.objectContaining({ heartbeatRunId: null, providerLeaseId: "owner", metadata: expect.objectContaining({ driver: "computer", computerOwner: { computerId: "computer", ownerId: "owner", generation: 1 } }) }));
});
});
describe("computer environment selection", () => {
const environment = { id: "environment", driver: "computer", status: "active", config: {}, metadata: { computerCompanyId: "owner" } };
const service = { getById: async () => environment };
it("permits the attached company and rejects another company", async () => {
await expect(assertEnvironmentSelectionForCompany(service, "owner", "environment")).resolves.toBeUndefined();
await expect(assertEnvironmentSelectionForCompany(service, "other", "environment")).rejects.toThrow("not available in this company");
});
});