Skip to content

Commit 9d1093f

Browse files
chore(stepfunctions): remove integ dependency (#24653)
Removes a dependency between a unit and integration test by extracting generic code into a separate file. Useful for repo restructure as integ tests are in a separate package. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 738fcfb commit 9d1093f

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as iam from '@aws-cdk/aws-iam';
2+
import * as constructs from 'constructs';
3+
import * as sfn from '../lib';
4+
5+
export interface FakeTaskProps extends sfn.TaskStateBaseProps {
6+
parameters?: { [key: string]: string };
7+
}
8+
9+
/**
10+
* Task extending sfn.TaskStateBase to facilitate integ testing setting credentials
11+
*/
12+
export class FakeTask extends sfn.TaskStateBase {
13+
protected readonly taskMetrics?: sfn.TaskMetricsConfig;
14+
protected readonly taskPolicies?: iam.PolicyStatement[];
15+
protected readonly parameters?: { [key: string]: string };
16+
17+
constructor(scope: constructs.Construct, id: string, props: FakeTaskProps = {}) {
18+
super(scope, id, props);
19+
this.parameters = props.parameters;
20+
}
21+
22+
protected _renderTask(): any {
23+
return {
24+
Type: 'Task',
25+
Resource: 'arn:aws:states:::dynamodb:putItem',
26+
Parameters: {
27+
TableName: 'my-cool-table',
28+
Item: {
29+
id: {
30+
S: 'my-entry',
31+
},
32+
},
33+
...this.parameters,
34+
},
35+
};
36+
}
37+
}

packages/@aws-cdk/aws-stepfunctions/test/integ.state-machine-credentials.ts

+1-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as cdk from '@aws-cdk/core';
33
import { IntegTest } from '@aws-cdk/integ-tests';
4-
import * as constructs from 'constructs';
4+
import { FakeTask } from './fake-task';
55
import * as sfn from '../lib';
66

7-
export interface FakeTaskProps extends sfn.TaskStateBaseProps {
8-
parameters?: { [key: string]: string };
9-
}
10-
11-
/**
12-
* Task extending sfn.TaskStateBase to facilitate integ testing setting credentials
13-
*/
14-
export class FakeTask extends sfn.TaskStateBase {
15-
protected readonly taskMetrics?: sfn.TaskMetricsConfig;
16-
protected readonly taskPolicies?: iam.PolicyStatement[];
17-
protected readonly parameters?: { [key: string]: string };
18-
19-
constructor(scope: constructs.Construct, id: string, props: FakeTaskProps = {}) {
20-
super(scope, id, props);
21-
this.parameters = props.parameters;
22-
}
23-
24-
protected _renderTask(): any {
25-
return {
26-
Type: 'Task',
27-
Resource: 'arn:aws:states:::dynamodb:putItem',
28-
Parameters: {
29-
TableName: 'my-cool-table',
30-
Item: {
31-
id: {
32-
S: 'my-entry',
33-
},
34-
},
35-
...this.parameters,
36-
},
37-
};
38-
}
39-
}
40-
417
/*
428
* Stack verification steps:
439
*

packages/@aws-cdk/aws-stepfunctions/test/state.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as cdk from '@aws-cdk/core';
2-
import { FakeTask } from './integ.state-machine-credentials';
2+
import { FakeTask } from './fake-task';
33
import { renderGraph } from './private/render-util';
44
import { JsonPath } from '../lib';
55

0 commit comments

Comments
 (0)