功能增加
This commit is contained in:
1 parent
b340fc7ad7
commit
f1993eb388
69 files changed
+2243
-162
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { queryDatabase } = vi.hoisted(() => ({ queryDatabase: vi.fn() }));
|
||||
|
||||
vi.mock("@/lib/server/database", () => ({
|
||||
isPostgresBackend: () => true,
|
||||
queryDatabase,
|
||||
withDatabaseTransaction: vi.fn()
|
||||
}));
|
||||
|
||||
import { getGenerationJob } from "@/lib/server/data-store";
|
||||
|
||||
describe("generation job MiniMax billing mapping", () => {
|
||||
beforeEach(() => queryDatabase.mockReset());
|
||||
|
||||
it("retains MiniMax actual usage when a PostgreSQL job is read", async () => {
|
||||
queryDatabase.mockResolvedValueOnce({
|
||||
rows: [{
|
||||
id: "job-h3",
|
||||
owner_id: "account-1",
|
||||
capability: "video.generate",
|
||||
provider: "minimax",
|
||||
req_key: "MiniMax-H3",
|
||||
status: "succeeded",
|
||||
input_asset_ids: [],
|
||||
input_urls: [],
|
||||
output_asset_ids: ["asset-1"],
|
||||
request_payload: {},
|
||||
billing: {
|
||||
priceRuleId: "base-minimax-h3-2k",
|
||||
provider: "minimax",
|
||||
capability: "video.generate",
|
||||
reqKey: "MiniMax-H3",
|
||||
unit: "video_second",
|
||||
quantity: 5,
|
||||
standardUnitPriceFen: 80,
|
||||
markupMultiplier: 1.2,
|
||||
amountFen: 480,
|
||||
currency: "CNY",
|
||||
status: "charged",
|
||||
settlementStatus: "settled",
|
||||
providerUsage: {
|
||||
model: "MiniMax-H3",
|
||||
resolution: "2K",
|
||||
outputSeconds: 5,
|
||||
inputVideoSeconds: 0,
|
||||
inputImageCount: 1,
|
||||
videoPriceFenPerSecond: 80
|
||||
}
|
||||
},
|
||||
created_at: new Date("2026-09-04T01:00:00.000Z"),
|
||||
updated_at: new Date("2026-09-04T01:05:00.000Z")
|
||||
}]
|
||||
});
|
||||
|
||||
const job = await getGenerationJob("job-h3");
|
||||
|
||||
expect(job?.billing?.providerUsage).toEqual({
|
||||
resolution: "2K",
|
||||
model: "MiniMax-H3",
|
||||
completionTokens: undefined,
|
||||
inputVideo: undefined,
|
||||
tokenPriceFenPerMillion: undefined,
|
||||
outputSeconds: 5,
|
||||
inputVideoSeconds: 0,
|
||||
inputImageCount: 1,
|
||||
videoPriceFenPerSecond: 80
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user