mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 00:14:34 +00:00
refactor(core): dedupe infra, media, pairing, and plugin helpers
This commit is contained in:
@@ -4,6 +4,15 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveAgentRoute } from "./resolve-route.js";
|
||||
|
||||
describe("resolveAgentRoute", () => {
|
||||
const resolveDiscordGuildRoute = (cfg: OpenClawConfig) =>
|
||||
resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "discord",
|
||||
accountId: "default",
|
||||
peer: { kind: "channel", id: "c1" },
|
||||
guildId: "g1",
|
||||
});
|
||||
|
||||
test("defaults to main/default when no bindings exist", () => {
|
||||
const cfg: OpenClawConfig = {};
|
||||
const route = resolveAgentRoute({
|
||||
@@ -123,13 +132,7 @@ describe("resolveAgentRoute", () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
const route = resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "discord",
|
||||
accountId: "default",
|
||||
peer: { kind: "channel", id: "c1" },
|
||||
guildId: "g1",
|
||||
});
|
||||
const route = resolveDiscordGuildRoute(cfg);
|
||||
expect(route.agentId).toBe("chan");
|
||||
expect(route.sessionKey).toBe("agent:chan:discord:channel:c1");
|
||||
expect(route.matchedBy).toBe("binding.peer");
|
||||
@@ -163,13 +166,7 @@ describe("resolveAgentRoute", () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
const route = resolveAgentRoute({
|
||||
cfg,
|
||||
channel: "discord",
|
||||
accountId: "default",
|
||||
peer: { kind: "channel", id: "c1" },
|
||||
guildId: "g1",
|
||||
});
|
||||
const route = resolveDiscordGuildRoute(cfg);
|
||||
expect(route.agentId).toBe("guild");
|
||||
expect(route.matchedBy).toBe("binding.guild");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user