fix(sites): integrate shared download access and register synced adapters

This commit is contained in:
root committed 2026-11-06 00:15:15 +08:00
1 parent 6dab134617
commit 36f3ece5b5
20 files changed
+175 -38

No files matched your search

@@ -1,6 +1,7 @@
import { TaskRegistry } from "@umt/tasks";
import { createMockMteamApi, type MockMteamApi } from "@umt/testkit";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { createPorts } from "../../src/modules/acquisition-organize/ports.ts";
import { snapshotSite } from "../../src/modules/sources-identity/service/snapshot.ts";
import { createHarness, type Harness, pgAvailable } from "./harness.ts";
@@ -50,6 +51,27 @@ describe.skipIf(!up)("M-Team 快照与任务注册", () => {
expect(JSON.stringify(rows)).not.toContain(api.apiKey);
});
it("下载种子沿用配置的 API 基址,并与站点访问共用 PG 限流桶", async () => {
const site = await h.db
.updateTable("site")
.set({ rate_limit: JSON.stringify({ minIntervalMs: 10, burst: 1 }) })
.where("id", "=", siteId)
.returningAll()
.executeTakeFirstOrThrow();
const release = await h.db
.selectFrom("source_release")
.selectAll()
.where("site_id", "=", siteId)
.executeTakeFirstOrThrow();
const before = api.issuedTokens;
const source = await createPorts(h.ctx).torrentSource({ release, site });
expect(source.kind).toBe("file");
expect(api.issuedTokens).toBe(before + 1);
expect(
await h.db.selectFrom("rate_limit_bucket").select("key").where("key", "=", `site:${siteId}`).executeTakeFirst(),
).toBeTruthy();
});
it("key 失效:账号标失效 + 待处理,快照结果 failed", async () => {
api.setFailMode("banned_key");
const r = await snapshotSite(h.rt, { siteId, kind: "manual" });