import type { AsyncFunction } from "async"; import type { ActionDeclarationInput } from "@garden-io/grow-sdk/actions/types"; import type { DeclaredAction } from "@garden-io/grow-sdk/declarations/action"; import type { DeclaredCommand } from "@garden-io/grow-sdk/declarations/command"; import type { PrimitiveMap } from "@garden-io/grow-sdk/util/types"; import { BaseAction } from "../actions/base"; import { ConfigWrapper } from "../config/wrapper"; import { GrowContext } from "../context"; import type { GrowOpts } from "../context"; import { MutableConfigGraph } from "../graph/config-graph"; import type { ConfigGraphParams } from "../graph/config-graph"; import type { GraphResultMapWithoutTask } from "../graph/results"; import type { Issue } from "../issues"; import type { Log } from "../logger/log-entry"; export declare function expectFuzzyMatch(str: string, sample: string | string[]): void; type ExpectErrorAssertion = string | ((err: Error) => void) | { type?: string; contains?: string | string[]; errorMessageGetter?: (err: unknown) => string; }; /** * _Temporary_ helper to expect async functions to NOT throw any errors. * There is an issue in `bun:test` with doing that, * see https://github.com/oven-sh/bun/issues/9687 * * FIXME: Use `expect(() => f(...)).resolve.not.toThrowError()` when the original Bun issue is fixed. * * @param fn an async function to test in a form of command GoF pattern, * i.e.`f(a, b)` should be wrapped as `() => f(a, b)` and passed in as an argument. */ export declare function expectNoErrorAsync(fn: () => Promise): Promise; export declare function expectError(fn: () => unknown | AsyncFunction, assertion?: ExpectErrorAssertion): void | Promise; export declare function equalWithPrecision(a: number, b: number, precision: number): boolean; export declare function freezeTime(date?: Date): Date; export declare function resetTimekeeper(): void; /** * Initialise test logger. * * It doesn't register any writers so it only collects logs but doesn't write them. */ export declare function initTestLogger(): void; /** * Returns a fully resolved path of a concrete path located in the {@link testDataDir}. * The path is defined as a varargs list of its directory names. * E.g. `"project", "service-1"` stands for the path `project/service-1`. * * @param names the subdirectory path */ export declare function getTestdataPath(...names: string[]): string; export declare function captureStream(stream: NodeJS.WritableStream): { unhook: () => void; captured: () => string; }; /** * Returns a map of all task results including dependencies from a GraphResultMap. */ export declare function getAllTaskResults(results: GraphResultMapWithoutTask): { [x: string]: import("../graph/results").GraphResultWithoutTask> | null; }; export declare class TestConfigGraph extends MutableConfigGraph { growRoot: string; constructor(params: ConfigGraphParams & { growRoot: string; }); addDeclaredAction(sdkAction: DeclaredAction): BaseAction>; addDeclaredActions(sdkActions: DeclaredAction[]): BaseAction>[]; } export declare function makeTestRunActionType(runHandler?: () => void): import("@garden-io/grow-sdk/declarations/action-type").ActionType<"test", "test", import("zod").ZodObject<{ foo: import("zod").ZodOptional; }, "strip", import("zod").ZodTypeAny, { foo?: string | undefined; }, { foo?: string | undefined; }>, { something: import("zod").ZodDefault; }>; export declare const testRunActionType: import("@garden-io/grow-sdk/declarations/action-type").ActionType<"test", "test", import("zod").ZodObject<{ foo: import("zod").ZodOptional; }, "strip", import("zod").ZodTypeAny, { foo?: string | undefined; }, { foo?: string | undefined; }>, { something: import("zod").ZodDefault; }>; export declare const testRunOutputs: Readonly<{ something: "something"; }>; /** * Initialise test logger. * * It doesn't register any writers so it only collects logs but doesn't write them. */ export declare function getTestLog(): import("../logger/log-entry").CoreLog; export declare function assertIsDefined(value: Value): asserts value is NonNullable; export declare class TestConfigWrapper extends ConfigWrapper { constructor(path: string, cliInputs: PrimitiveMap); getConfigDirPath(): string; loadModule(_: Log): Promise; } export declare class TestGrowContext extends GrowContext { readonly configWrapper: TestConfigWrapper; constructor(params: Omit, basePath?: string); addAction(log: Log, sdkAction: DeclaredAction): void; addCommand(log: Log, sdkCommand: DeclaredCommand): void; /** * Creates and adds a test Run action to the context. * Also sets the action's source to the basePath and defaults `include` to an empty array. */ makeTestAction(log: Log, config: ActionDeclarationInput): DeclaredAction; }, "strip", import("zod").ZodTypeAny, { foo?: string | undefined; }, { foo?: string | undefined; }>, { something: import("zod").ZodDefault; }>>; } /** * Create a TestGrowContext with a temporary directory as the base path (unless one is provided in the second arg). */ export declare function makeTestContext(params: Omit, basePath?: string): Promise; export {};