Skip to content

Commit

Permalink
Fix to set boolean in params.Publish (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
abetomo authored and DeviaVir committed Jul 5, 2017
1 parent 09c2cd8 commit b43cacd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ Lambda.prototype._params = (program, buffer) => {
Description: program.description,
MemorySize: program.memorySize,
Timeout: program.timeout,
Publish: program.publish,
Publish: (() => {
if (typeof program.publish === 'boolean') {
return program.publish
}
return program.publish === 'true'
})(),
VpcConfig: {
SubnetIds: [],
SecurityGroupIds: []
Expand Down
29 changes: 29 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,35 @@ describe('lib/main', function () {
assert.isNull(params.TracingConfig.Mode)
})

describe('params.Publish', () => {
describe('boolean', () => {
it('If true, it is set to true', () => {
program.publish = true
const params = lambda._params(program)
assert.isTrue(params.Publish)
})
it('If false, it is set to false', () => {
program.publish = false
const params = lambda._params(program)
assert.isFalse(params.Publish)
})
})

describe('string', () => {
it('If "true", it is set to true', () => {
program.publish = 'true'
const params = lambda._params(program)
assert.isTrue(params.Publish)
})
it('If not "true", it is set to false', () => {
program.publish = 'false'
assert.isFalse(lambda._params(program).Publish)
program.publish = 'aaa'
assert.isFalse(lambda._params(program).Publish)
})
})
})

describe('configFile', () => {
beforeEach(() => {
// Prep...
Expand Down

0 comments on commit b43cacd

Please sign in to comment.