mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
* test(status): deslop s223 tests * test(onepassword): deslop s225 tests * test(mcp): deslop s224 tests * test(scripts): deslop s215 tests * test(fal): deslop s226 tests * test(feishu): deslop s227 tests * test(amazon-bedrock-mantle): deslop s229 tests * test(lobster): deslop s234 tests * test(comfy): deslop s228 tests * test(irc): deslop s230 tests
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
MAX_PRIVATE_QA_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES,
|
|
MAX_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES,
|
|
PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES,
|
|
evaluatePluginSdkDeclarationBudget,
|
|
isPrivateQaPluginSdkBuild,
|
|
} from "../../scripts/lib/plugin-sdk-declaration-budget.mts";
|
|
|
|
describe("plugin SDK declaration budget", () => {
|
|
it("selects private QA mode only for the explicit build flag", () => {
|
|
expect(isPrivateQaPluginSdkBuild({})).toBe(false);
|
|
expect(isPrivateQaPluginSdkBuild({ OPENCLAW_BUILD_PRIVATE_QA: "0" })).toBe(false);
|
|
expect(isPrivateQaPluginSdkBuild({ OPENCLAW_BUILD_PRIVATE_QA: "1" })).toBe(true);
|
|
});
|
|
|
|
it.each([
|
|
[false, "public", MAX_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES],
|
|
[true, "private-qa-public-entry", MAX_PRIVATE_QA_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES],
|
|
] as const)(
|
|
"enforces the %s build's %s budget at its exact boundary",
|
|
(buildPrivateQa, budgetKind, ratchetBytes) => {
|
|
const budgetBytes = ratchetBytes + PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES;
|
|
const expected = {
|
|
budgetBytes,
|
|
budgetKind,
|
|
ratchetBytes,
|
|
shouldFail: false,
|
|
varianceBytes: PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES,
|
|
};
|
|
expect(
|
|
evaluatePluginSdkDeclarationBudget({
|
|
buildPrivateQa,
|
|
declarationBytes: budgetBytes,
|
|
}),
|
|
).toEqual(expected);
|
|
expect(
|
|
evaluatePluginSdkDeclarationBudget({
|
|
buildPrivateQa,
|
|
declarationBytes: budgetBytes + 1,
|
|
}),
|
|
).toEqual({ ...expected, shouldFail: true });
|
|
},
|
|
);
|
|
});
|