refactor(test): dedupe setup wizard helpers

This commit is contained in:
Peter Steinberger
2026-03-22 00:15:51 +00:00
parent 85722d4cf2
commit 30ad059da8
27 changed files with 322 additions and 186 deletions

View File

@@ -1,7 +1,9 @@
import type { RuntimeEnv } from "openclaw/plugin-sdk/testing";
import { vi } from "vitest";
export function createRuntimeEnv(options?: { throwOnExit?: boolean }): RuntimeEnv {
export function createRuntimeEnv<TRuntime = RuntimeEnv>(options?: {
throwOnExit?: boolean;
}): RuntimeEnv {
const throwOnExit = options?.throwOnExit ?? true;
return {
log: vi.fn(),
@@ -13,3 +15,15 @@ export function createRuntimeEnv(options?: { throwOnExit?: boolean }): RuntimeEn
: vi.fn(),
};
}
export function createTypedRuntimeEnv<TRuntime>(options?: { throwOnExit?: boolean }): TRuntime {
return createRuntimeEnv(options) as TRuntime;
}
export function createNonExitingRuntimeEnv(): RuntimeEnv {
return createRuntimeEnv({ throwOnExit: false });
}
export function createNonExitingTypedRuntimeEnv<TRuntime>(): TRuntime {
return createTypedRuntimeEnv<TRuntime>({ throwOnExit: false });
}