mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-10-19 05:20:05 +00:00
Validated in a combined board on the current release tip: focused node:test + vitest suites, typecheck:core, open-sse typecheck, gate-manifest, mutation-test-coverage, file-size, changelog-integrity, complexity, env-doc-sync, test-discovery, vitest-exclusions, error-helper, cli-i18n and the i18n new-keys/ui-coverage gates green. Thank you for the contribution.
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { getModelPricing, KNOWN_MODEL_PRICING } from "../../open-sse/services/providerCostData.ts";
|
|
|
|
test("provider-specific pricing wins over a generic model fallback", () => {
|
|
const genericKey = "provider-price-test-model";
|
|
const providerKey = `devin-cli/${genericKey}`;
|
|
const previousGeneric = KNOWN_MODEL_PRICING[genericKey];
|
|
const previousProvider = KNOWN_MODEL_PRICING[providerKey];
|
|
|
|
KNOWN_MODEL_PRICING[genericKey] = {
|
|
inputCostPer1M: 9,
|
|
outputCostPer1M: 90,
|
|
isFree: false,
|
|
};
|
|
KNOWN_MODEL_PRICING[providerKey] = {
|
|
inputCostPer1M: 1,
|
|
outputCostPer1M: 10,
|
|
isFree: false,
|
|
};
|
|
|
|
try {
|
|
assert.deepEqual(getModelPricing("devin-cli", genericKey), {
|
|
inputCostPer1M: 1,
|
|
outputCostPer1M: 10,
|
|
isFree: false,
|
|
isEstimated: false,
|
|
});
|
|
} finally {
|
|
if (previousGeneric) KNOWN_MODEL_PRICING[genericKey] = previousGeneric;
|
|
else delete KNOWN_MODEL_PRICING[genericKey];
|
|
if (previousProvider) KNOWN_MODEL_PRICING[providerKey] = previousProvider;
|
|
else delete KNOWN_MODEL_PRICING[providerKey];
|
|
}
|
|
});
|
|
|
|
test("tier pricing reads the exact Devin provider/model rate", () => {
|
|
assert.deepEqual(getModelPricing("devin-cli", "gpt-5-6-luna-max"), {
|
|
inputCostPer1M: 0.2,
|
|
outputCostPer1M: 1.2,
|
|
isFree: false,
|
|
isEstimated: false,
|
|
});
|
|
assert.deepEqual(getModelPricing("devin-cli", "gpt-5-6-luna-max-priority"), {
|
|
inputCostPer1M: 0.4,
|
|
outputCostPer1M: 2.4,
|
|
isFree: false,
|
|
isEstimated: false,
|
|
});
|
|
});
|