refactor(core): migrate to Bun and converge acquisition policies and Agent boundaries
This commit is contained in:
1 parent
3f1c6d02f6
commit
27c0f27434
268 files changed
+7468
-7852
No files matched your search
@@ -2,7 +2,6 @@ import { type EventType, isEventType, LIFECYCLE_EVENTS, parseEventPayload } from
|
||||
import { OutboxRelay } from "@umt/tasks";
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { collectOutboxRoutes } from "../../src/context.ts";
|
||||
import { HookRegistry } from "../../src/hooks/index.ts";
|
||||
import {
|
||||
emitDownloadLifecycle,
|
||||
emitScrapeFinished,
|
||||
@@ -78,7 +77,7 @@ describe.skipIf(!hasPg)("生命周期广播事件(真实 PG)", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("订阅完成:发已完成(按历史行去重);钩子 subscription.completion.check 拒绝时不完成、不发事件", async () => {
|
||||
it("订阅完成:发已完成(按历史行去重),重复完成不重复发事件", async () => {
|
||||
const e = await seedEntity(h.db, { kind: "movie", title: "完成判定片", year: 2023 });
|
||||
const sub = await h.db
|
||||
.insertInto("subscription")
|
||||
@@ -86,26 +85,6 @@ describe.skipIf(!hasPg)("生命周期广播事件(真实 PG)", () => {
|
||||
.returningAll()
|
||||
.executeTakeFirstOrThrow();
|
||||
|
||||
const hooks = new HookRegistry();
|
||||
const seen: unknown[] = [];
|
||||
hooks.forModule("test").intercept("subscription.completion.check", (c) => {
|
||||
seen.push(c);
|
||||
return "还要等导演剪辑版";
|
||||
});
|
||||
h.ctx.hooks = hooks;
|
||||
try {
|
||||
const done = await h.db.transaction().execute((trx) => completeSubscription(h.d, trx, sub, "slot_satisfied"));
|
||||
expect(done).toBe(false);
|
||||
} finally {
|
||||
h.ctx.hooks = undefined;
|
||||
}
|
||||
expect(seen).toEqual([
|
||||
{ subscriptionId: sub.id, mediaEntityId: e, mediaKind: "movie", reason: "slot_satisfied", progress: {} },
|
||||
]);
|
||||
const still = await h.db.selectFrom("subscription").select("status").where("id", "=", sub.id).executeTakeFirst();
|
||||
expect(still?.status).toBe("active");
|
||||
expect((await events("subscription.completed")).filter((r) => r.payload.subscriptionId === sub.id)).toEqual([]);
|
||||
|
||||
expect(await h.db.transaction().execute((trx) => completeSubscription(h.d, trx, sub, "slot_satisfied"))).toBe(true);
|
||||
// 已完成的再判一次不会重复发
|
||||
expect(await h.db.transaction().execute((trx) => completeSubscription(h.d, trx, sub, "slot_satisfied"))).toBe(
|
||||
|
||||
Reference in new issue
Block a user