mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix: retain env-backed ClickClack accounts
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
listClickClackAccountIds,
|
||||
resolveClickClackAccount,
|
||||
@@ -11,6 +11,10 @@ import {
|
||||
import type { CoreConfig } from "./types.js";
|
||||
|
||||
describe("ClickClack account resolution", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("preserves top-level default account when named accounts are configured", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
@@ -137,7 +141,9 @@ describe("ClickClack account resolution", () => {
|
||||
},
|
||||
} satisfies CoreConfig;
|
||||
const env = { CLICKCLACK_BOT_TOKEN: " default-env-token " };
|
||||
vi.stubEnv("CLICKCLACK_BOT_TOKEN", env.CLICKCLACK_BOT_TOKEN);
|
||||
|
||||
expect(listClickClackAccountIds(cfg)).toEqual(["default", "work"]);
|
||||
expect(resolveClickClackAccount({ cfg, env }).token).toBe("default-env-token");
|
||||
expect(resolveClickClackAccount({ cfg, accountId: "work", env }).token).toBe("");
|
||||
});
|
||||
|
||||
@@ -32,7 +32,9 @@ const {
|
||||
const channel = cfg.channels?.clickclack;
|
||||
return Boolean(
|
||||
channel?.baseUrl?.trim() &&
|
||||
(hasConfiguredAccountValue(channel.token) || Boolean(channel.tokenFile?.trim())) &&
|
||||
(hasConfiguredAccountValue(channel.token) ||
|
||||
Boolean(channel.tokenFile?.trim()) ||
|
||||
Boolean(process.env.CLICKCLACK_BOT_TOKEN?.trim())) &&
|
||||
channel.workspace?.trim(),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user