mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:47:39 +00:00
fix: align channel config schemas and env precedence
This commit is contained in:
@@ -27,7 +27,7 @@ describe("resolveTelegramAccount", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("prefers TELEGRAM_BOT_TOKEN when accountId is omitted", () => {
|
||||
it("uses TELEGRAM_BOT_TOKEN when default account config is missing", () => {
|
||||
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
|
||||
try {
|
||||
@@ -50,6 +50,29 @@ describe("resolveTelegramAccount", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("prefers default config token over TELEGRAM_BOT_TOKEN", () => {
|
||||
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||
process.env.TELEGRAM_BOT_TOKEN = "tok-env";
|
||||
try {
|
||||
const cfg: ClawdbotConfig = {
|
||||
channels: {
|
||||
telegram: { botToken: "tok-config" },
|
||||
},
|
||||
};
|
||||
|
||||
const account = resolveTelegramAccount({ cfg });
|
||||
expect(account.accountId).toBe("default");
|
||||
expect(account.token).toBe("tok-config");
|
||||
expect(account.tokenSource).toBe("config");
|
||||
} finally {
|
||||
if (prevTelegramToken === undefined) {
|
||||
delete process.env.TELEGRAM_BOT_TOKEN;
|
||||
} else {
|
||||
process.env.TELEGRAM_BOT_TOKEN = prevTelegramToken;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("does not fall back when accountId is explicitly provided", () => {
|
||||
const prevTelegramToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||
process.env.TELEGRAM_BOT_TOKEN = "";
|
||||
|
||||
Reference in New Issue
Block a user