mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:42:44 +00:00
Channels: move single-account config into accounts.default (#27334)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 50b5771808
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
da6a96ed33
commit
dfa0b5b4fc
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { collectMissingDefaultAccountBindingWarnings } from "./doctor-config-flow.js";
|
||||
|
||||
describe("collectMissingDefaultAccountBindingWarnings", () => {
|
||||
it("warns when named accounts exist without default and no valid binding exists", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
alerts: { botToken: "a" },
|
||||
work: { botToken: "w" },
|
||||
},
|
||||
},
|
||||
},
|
||||
bindings: [{ agentId: "ops", match: { channel: "telegram" } }],
|
||||
};
|
||||
|
||||
const warnings = collectMissingDefaultAccountBindingWarnings(cfg);
|
||||
expect(warnings).toHaveLength(1);
|
||||
expect(warnings[0]).toContain("channels.telegram");
|
||||
expect(warnings[0]).toContain("alerts, work");
|
||||
});
|
||||
|
||||
it("does not warn when an explicit account binding exists", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
alerts: { botToken: "a" },
|
||||
},
|
||||
},
|
||||
},
|
||||
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "alerts" } }],
|
||||
};
|
||||
|
||||
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
|
||||
});
|
||||
|
||||
it("warns when bindings cover only a subset of configured accounts", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
alerts: { botToken: "a" },
|
||||
work: { botToken: "w" },
|
||||
},
|
||||
},
|
||||
},
|
||||
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "alerts" } }],
|
||||
};
|
||||
|
||||
const warnings = collectMissingDefaultAccountBindingWarnings(cfg);
|
||||
expect(warnings).toHaveLength(1);
|
||||
expect(warnings[0]).toContain("subset");
|
||||
expect(warnings[0]).toContain("Uncovered accounts: work");
|
||||
});
|
||||
|
||||
it("does not warn when wildcard account binding exists", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
alerts: { botToken: "a" },
|
||||
},
|
||||
},
|
||||
},
|
||||
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "*" } }],
|
||||
};
|
||||
|
||||
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not warn when default account is present", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
default: { botToken: "d" },
|
||||
alerts: { botToken: "a" },
|
||||
},
|
||||
},
|
||||
},
|
||||
bindings: [{ agentId: "ops", match: { channel: "telegram" } }],
|
||||
};
|
||||
|
||||
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user