Merge pull request #23288 from backstage/blam/simplify-test-utils

chore: simplify the input types for `createMockActionContext`
This commit is contained in:
Patrik Oldsberg
2024-02-27 16:40:13 +01:00
committed by GitHub
2 changed files with 6 additions and 28 deletions
@@ -3,30 +3,15 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
/// <reference types="node" />
import { ActionContext } from '@backstage/plugin-scaffolder-node';
import { JsonObject } from '@backstage/types';
import { TaskSecrets } from '@backstage/plugin-scaffolder-node';
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
import * as winston from 'winston';
import { Writable } from 'stream';
// @public
export const createMockActionContext: <
TActionInput extends JsonObject = JsonObject,
TActionOutput extends JsonObject = JsonObject,
>(
options?:
| {
input?: TActionInput | undefined;
logger?: winston.Logger | undefined;
logStream?: Writable | undefined;
secrets?: TaskSecrets | undefined;
templateInfo?: TemplateInfo | undefined;
workspacePath?: string | undefined;
}
| undefined,
options?: Partial<ActionContext<TActionInput, TActionOutput>> | undefined,
) => ActionContext<TActionInput, TActionOutput>;
// (No @packageDocumentation comment for this package)
@@ -14,13 +14,11 @@
* limitations under the License.
*/
import { PassThrough, Writable } from 'stream';
import { PassThrough } from 'stream';
import { getVoidLogger } from '@backstage/backend-common';
import { createMockDirectory } from '@backstage/backend-test-utils';
import { JsonObject } from '@backstage/types';
import { ActionContext, TaskSecrets } from '@backstage/plugin-scaffolder-node';
import * as winston from 'winston';
import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
import { ActionContext } from '@backstage/plugin-scaffolder-node';
/**
* A utility method to create a mock action context for scaffolder actions.
@@ -31,14 +29,9 @@ import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
export const createMockActionContext = <
TActionInput extends JsonObject = JsonObject,
TActionOutput extends JsonObject = JsonObject,
>(options?: {
input?: TActionInput;
logger?: winston.Logger;
logStream?: Writable;
secrets?: TaskSecrets;
templateInfo?: TemplateInfo;
workspacePath?: string;
}): ActionContext<TActionInput, TActionOutput> => {
>(
options?: Partial<ActionContext<TActionInput, TActionOutput>>,
): ActionContext<TActionInput, TActionOutput> => {
const defaultContext = {
logger: getVoidLogger(),
logStream: new PassThrough(),