Skip to content

Commit

Permalink
Merge pull request #663 from JupiterOne/allow-empty-dependency-graph-…
Browse files Browse the repository at this point in the history
…id-in-executeStepWithDependencies

Support executeStepWithDependencies for steps with no dependencyGraphId
  • Loading branch information
ndowmon committed Apr 11, 2022
2 parents a49a9b0 + c91fe57 commit dcd4477
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,11 @@ and this project adheres to

## Unreleased

### Changed

- Support `executeStepWithDependencies` for steps with no `dependencyGraphId`,
even if `invocationConfig.dependencyGraphOrder` is present

## [8.11.0] - 2022-04-11

### Added
Expand Down
Expand Up @@ -65,17 +65,22 @@ describe('executeStepWithDependencies', () => {
});

describe('invalid invocationConfig', () => {
test('should fail if invocationConfig `dependencyGraphOrder` property is present', async () => {
test('should fail if `step.dependencyGraphId` property is present', async () => {
await expect(
executeStepWithDependencies({
stepId: 'step-1',
invocationConfig: getMockInvocationConfig({
dependencyGraphOrder: [],
integrationSteps: [
getMockIntegrationStep({
id: 'step-1',
dependencyGraphId: 'last',
}),
],
}),
instanceConfig: getMockInstanceConfig(),
}),
).rejects.toThrow(
'executeStepWithDependencies does not currently support dependencyGraphOrder',
'executeStepWithDependencies does not currently support steps with a dependencyGraphId',
);
});

Expand Down
Expand Up @@ -9,16 +9,17 @@ import {
export async function executeStepWithDependencies(params: StepTestConfig) {
const { stepId, invocationConfig, instanceConfig } = params;

if (invocationConfig.dependencyGraphOrder) {
throw new Error(
'executeStepWithDependencies does not currently support dependencyGraphOrder',
);
}

const stepDependencyGraph = buildStepDependencyGraph(
invocationConfig.integrationSteps,
);

const step = stepDependencyGraph.getNodeData(stepId);
if (step.dependencyGraphId) {
throw new Error(
'executeStepWithDependencies does not currently support steps with a dependencyGraphId',
);
}

const dependencyStepIds = stepDependencyGraph.dependenciesOf(stepId);

const executionConfig = invocationConfig.loadExecutionConfig
Expand Down Expand Up @@ -48,8 +49,7 @@ export async function executeStepWithDependencies(params: StepTestConfig) {
executionConfig,
};

const { executionHandler } = stepDependencyGraph.getNodeData(stepId);
await executionHandler(context);
await step.executionHandler(context);

return {
collectedEntities: context.jobState.collectedEntities,
Expand Down

0 comments on commit dcd4477

Please sign in to comment.