mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 18:09:43 +00:00
Add setFailed to ActionsEnv
This commit is contained in:
@@ -30,6 +30,7 @@ declare const __CODEQL_ACTION_VERSION__: string;
|
||||
export interface ActionsEnv {
|
||||
getRequiredInput: (name: string) => string;
|
||||
getOptionalInput: (name: string) => string | undefined;
|
||||
setFailed: (message: string) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,7 @@ export function getActionsEnv(): ActionsEnv {
|
||||
return {
|
||||
getRequiredInput,
|
||||
getOptionalInput,
|
||||
setFailed: core.setFailed,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -227,8 +227,13 @@ export function getTestEnv(testEnv: NodeJS.ProcessEnv = {}): Env {
|
||||
return getEnv(testEnv);
|
||||
}
|
||||
|
||||
/** An implementation of `ActionsEnv` for use in tests. */
|
||||
/**
|
||||
* An implementation of {@link ActionsEnv} for use in tests.
|
||||
* The methods of instances of this class are intended to be stubbed.
|
||||
*/
|
||||
class TestActionsEnv implements ActionsEnv {
|
||||
private failed: boolean = false;
|
||||
|
||||
constructor(private readonly env: Env) {}
|
||||
|
||||
public clone(env: Env): this {
|
||||
@@ -242,6 +247,14 @@ class TestActionsEnv implements ActionsEnv {
|
||||
public getOptionalInput(_name: string): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public setFailed(_message: string) {
|
||||
this.failed = true;
|
||||
}
|
||||
|
||||
get hasFailed() {
|
||||
return this.failed;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user