mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Add ActionsEnv support to ActionState
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ActionsEnv } from "./actions-util";
|
||||
import { Env } from "./environment";
|
||||
import { FeatureEnablement } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
@@ -12,6 +13,10 @@ export interface FeatureState {
|
||||
/** Information about environment variables. */
|
||||
env: Env;
|
||||
};
|
||||
Actions: {
|
||||
/** Access to Actions-related functionality. */
|
||||
actions: ActionsEnv;
|
||||
};
|
||||
FeatureFlags: {
|
||||
/** Information about enabled feature flags. */
|
||||
features: FeatureEnablement;
|
||||
|
||||
@@ -11,7 +11,12 @@ import nock from "nock";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import { ActionState, StateFeature } from "./action-common";
|
||||
import { ActionsEnv, ActionsEnvVars, getActionVersion } from "./actions-util";
|
||||
import {
|
||||
ActionsEnv,
|
||||
ActionsEnvVars,
|
||||
getActionsEnv,
|
||||
getActionVersion,
|
||||
} from "./actions-util";
|
||||
import { AnalysisKind } from "./analyses";
|
||||
import * as apiClient from "./api-client";
|
||||
import { GitHubApiDetails } from "./api-client";
|
||||
@@ -190,7 +195,7 @@ export function getTestActionsEnv(): ActionsEnv {
|
||||
}
|
||||
|
||||
/** For testing purposes, we make all available state features accessible in `TestEnv`. */
|
||||
type AllState = ["Logger", "Env", "FeatureFlags"];
|
||||
type AllState = ["Logger", "Env", "Actions", "FeatureFlags"];
|
||||
|
||||
/**
|
||||
* Wraps a function that accepts an `ActionState` for testing in different environments.
|
||||
@@ -218,6 +223,7 @@ export class TestEnv<
|
||||
: {
|
||||
logger: new RecordingLogger(),
|
||||
env: getTestEnv(),
|
||||
actions: getActionsEnv(),
|
||||
features: createFeatures([]),
|
||||
};
|
||||
}
|
||||
@@ -256,6 +262,12 @@ export class TestEnv<
|
||||
return result;
|
||||
}
|
||||
|
||||
public withActions(actions: ActionsEnv): TestEnv<Args, R, Fs> {
|
||||
const result = this.clone();
|
||||
result.state.actions = actions;
|
||||
return result;
|
||||
}
|
||||
|
||||
call(): R {
|
||||
if (!this.args) {
|
||||
throw new Error("Trying to call function in TestEnv without arguments.");
|
||||
|
||||
Reference in New Issue
Block a user