22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
import { BadRequestException } from "@nestjs/common";
|
|
import { ModelTierPolicyService } from "./model-tier-policy.service";
|
|
|
|
describe("ModelTierPolicyService", () => {
|
|
const policy = new ModelTierPolicyService();
|
|
|
|
it.each([
|
|
[{ complexity: 0, risk: 0, operationMode: "OBSERVE", remainingBudgetCents: 1 }, "L0"],
|
|
[{ complexity: 2, risk: 1, operationMode: "PREPARE", remainingBudgetCents: 100 }, "L1"],
|
|
[{ complexity: 5, risk: 4, operationMode: "PREPARE", remainingBudgetCents: 500 }, "L2"],
|
|
[{ complexity: 7, risk: 7, operationMode: "PREPARE", remainingBudgetCents: 1500 }, "L3"],
|
|
[{ complexity: 9, risk: 9, operationMode: "MUTATE_PRODUCTION", remainingBudgetCents: 5000 }, "L4"],
|
|
])("selects a deterministic tier for policy inputs", (input, expected) => {
|
|
expect(policy.select(input as never)).toBe(expected);
|
|
expect(policy.select(input as never)).toBe(expected);
|
|
});
|
|
|
|
it("fails closed when the selected tier exceeds the remaining hard budget", () => {
|
|
expect(() => policy.select({ complexity: 9, risk: 9, operationMode: "MUTATE_PRODUCTION", remainingBudgetCents: 100 })).toThrow(BadRequestException);
|
|
});
|
|
});
|