mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 11:30:41 +00:00
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { evaluateRuntimeEligibility } from "./config-eval.js";
|
|
|
|
describe("evaluateRuntimeEligibility", () => {
|
|
it("rejects entries when required OS does not match local or remote", () => {
|
|
const result = evaluateRuntimeEligibility({
|
|
os: ["definitely-not-a-runtime-platform"],
|
|
remotePlatforms: [],
|
|
hasBin: () => true,
|
|
hasEnv: () => true,
|
|
isConfigPathTruthy: () => true,
|
|
});
|
|
expect(result).toBe(false);
|
|
});
|
|
|
|
it("accepts entries when remote platform satisfies OS requirements", () => {
|
|
const result = evaluateRuntimeEligibility({
|
|
os: ["linux"],
|
|
remotePlatforms: ["linux"],
|
|
hasBin: () => true,
|
|
hasEnv: () => true,
|
|
isConfigPathTruthy: () => true,
|
|
});
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it("bypasses runtime requirements when always=true", () => {
|
|
const result = evaluateRuntimeEligibility({
|
|
always: true,
|
|
requires: { env: ["OPENAI_API_KEY"] },
|
|
hasBin: () => false,
|
|
hasEnv: () => false,
|
|
isConfigPathTruthy: () => false,
|
|
});
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it("evaluates runtime requirements when always is false", () => {
|
|
const result = evaluateRuntimeEligibility({
|
|
requires: {
|
|
bins: ["node"],
|
|
anyBins: ["bun", "node"],
|
|
env: ["OPENAI_API_KEY"],
|
|
config: ["browser.enabled"],
|
|
},
|
|
hasBin: (bin) => bin === "node",
|
|
hasAnyRemoteBin: () => false,
|
|
hasEnv: (name) => name === "OPENAI_API_KEY",
|
|
isConfigPathTruthy: (path) => path === "browser.enabled",
|
|
});
|
|
expect(result).toBe(true);
|
|
});
|
|
});
|