Skip to content

Commit 5f6b91f

Browse files
committed
add invoke test
1 parent e529427 commit 5f6b91f

File tree

5 files changed

+343
-33
lines changed

5 files changed

+343
-33
lines changed

lib/deploy/events/apiGateway/endpointInfo.test.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ describe('#getEndpointInfo()', () => {
1818
serverless.setProvider('aws', new AwsProvider(serverless));
1919
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
2020
serverless.service.service = 'new-service';
21-
serverless.service.stepfunctions = {
22-
stateMachines: {
23-
first: {
24-
events: [
25-
{
26-
http: {
27-
path: 'foo/bar',
28-
method: 'POST',
29-
},
30-
},
31-
],
32-
},
33-
},
34-
};
3521
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
3622
});
3723

lib/deploy/events/apiGateway/restApi.test.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ describe('#compileRestApi()', () => {
2525
serverless.setProvider('aws', new AwsProvider(serverless));
2626
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
2727
serverless.service.service = 'new-service';
28-
serverless.service.stepfunctions = {
29-
stateMachines: {
30-
first: {
31-
events: [
32-
{
33-
http: {
34-
path: 'foo/bar',
35-
method: 'POST',
36-
},
37-
},
38-
],
39-
},
40-
},
41-
};
4228
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
4329
});
4430

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ServerlessStepFunctions {
116116
.then(this.startExecution)
117117
.then(this.describeExecution)
118118
.then((result) => {
119+
this.serverless.cli.consoleLog('');
119120
if (result.status === 'FAILED') {
120121
return this.getExecutionHistory()
121122
.then((error) => {

lib/invoke/invoke.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
},
3636

3737
startExecution() {
38-
let inputData;
38+
let inputData = '';
3939

4040
if (this.options.data) {
4141
inputData = this.options.data;
@@ -49,12 +49,16 @@ module.exports = {
4949
inputData = JSON.stringify(this.serverless.utils.readFileSync(absolutePath));
5050
}
5151

52+
const params = {
53+
stateMachineArn: this.stateMachineArn,
54+
};
55+
56+
if (inputData) {
57+
params.input = inputData;
58+
}
5259
return this.provider.request('StepFunctions',
5360
'startExecution',
54-
{
55-
stateMachineArn: this.stateMachineArn,
56-
input: inputData,
57-
},
61+
params,
5862
this.options.stage,
5963
this.options.region)
6064
.then((result) => {

0 commit comments

Comments
 (0)