Skip to content

Commit

Permalink
Merge branch 'master' into StringValue
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-murashkin authored Sep 13, 2017
2 parents 44d5750 + 7a00388 commit a38d98c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = class TracingConfigPlugin {

toggleTracing(functionName, isEnabled) {
this.serverless.cli.log(`Tracing ${isEnabled ? 'ENABLED' : 'DISABLED'} for function "${functionName}"`);
return this.aws.request('Lambda', 'updateFunctionConfiguration', {
return this.options.noDeploy ? Promise.resolve(void 'noop') : this.aws.request('Lambda', 'updateFunctionConfiguration', {
FunctionName: functionName,
TracingConfig: {
Mode: isEnabled === true ? 'Active' : 'PassThrough'
Expand Down
18 changes: 17 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('serverless-plugin-tracing', function() {
params.provider);

serverlessInstance.service.functions = params.functions;
const options = { stage: 'test' };
const options = { stage: 'test', noDeploy: params.noDeploy };
const plugin = new Plugin(serverlessInstance, options);
plugin.hooks['after:deploy:deploy'].call(plugin);
return plugin;
Expand Down Expand Up @@ -216,4 +216,20 @@ describe('serverless-plugin-tracing', function() {
}
]);
});

it('noDeploy: enables tracing when function.tracing=true, but does not execute AWS request', function() {
runPlugin({
noDeploy: true,
functions: {
mainFunction: {
tracing: true
}
},
provider: {
}
});

assert.deepEqual(logSpy.getCall(0).args[0], 'Tracing ENABLED for function "myService-test-mainFunction"');
assert.isNull(requestSpy.getCall(0), 'no `aws.request`');
});
});

0 comments on commit a38d98c

Please sign in to comment.