mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 04:07:28 +00:00
refactor(extensions): dedupe channel config, onboarding, and monitors
This commit is contained in:
33
extensions/test-utils/start-account-context.ts
Normal file
33
extensions/test-utils/start-account-context.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type {
|
||||
ChannelAccountSnapshot,
|
||||
ChannelGatewayContext,
|
||||
OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk";
|
||||
import { vi } from "vitest";
|
||||
import { createRuntimeEnv } from "./runtime-env.js";
|
||||
|
||||
export function createStartAccountContext<TAccount extends { accountId: string }>(params: {
|
||||
account: TAccount;
|
||||
abortSignal: AbortSignal;
|
||||
statusPatchSink?: (next: ChannelAccountSnapshot) => void;
|
||||
}): ChannelGatewayContext<TAccount> {
|
||||
const snapshot: ChannelAccountSnapshot = {
|
||||
accountId: params.account.accountId,
|
||||
configured: true,
|
||||
enabled: true,
|
||||
running: false,
|
||||
};
|
||||
return {
|
||||
accountId: params.account.accountId,
|
||||
account: params.account,
|
||||
cfg: {} as OpenClawConfig,
|
||||
runtime: createRuntimeEnv(),
|
||||
abortSignal: params.abortSignal,
|
||||
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
|
||||
getStatus: () => snapshot,
|
||||
setStatus: (next) => {
|
||||
Object.assign(snapshot, next);
|
||||
params.statusPatchSink?.(snapshot);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user