You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 插入一条「已超时」的 processing 记录,用于验证 timeout-sweeper
* 用法npx tsx scripts/seed-timeout-test.ts
*/
import { config } from "dotenv";
config();
import { Prisma } from "@prisma/client";
import { prisma } from "../lib/prisma";
const QUOTE_ID = "QTE_TIMEOUT_TEST_001";
async function main() {
const backdated = new Date(Date.now() - 35_000);
await prisma.quoteRecord.upsert({
where: { quoteId: QUOTE_ID },
create: {
quoteId: QUOTE_ID,
requestId: "timeout-test-request-id-0001",
customerId: "CUST_001",
cargoHash: "timeout_test_hash_000000000001",
status: "processing",
isRealtime: true,
pickupJson: { city: "Los Angeles", state: "CA" },
deliveryJson: { city: "Dallas", state: "TX" },
weightLb: 500,
dimLIn: 48,
dimWIn: 40,
dimHIn: 48,
palletCount: 2,
cargoType: "general_freight",
createdAt: backdated,
updatedAt: backdated,
},
update: {
status: "processing",
errorCode: null,
sourceType: null,
quotesJson: Prisma.DbNull,
validUntil: null,
createdAt: backdated,
updatedAt: backdated,
},
});
console.log(`已写入测试记录 quote_id=${QUOTE_ID}created_at 回溯 35s`);
console.log("下一步npm run worker:scheduler -- --once");
console.log("预期status=failederror_code=QUOTE_TIMEOUT");
}
main()
.catch((error) => {
console.error("写入失败:", error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});