Skip to content

Commit

Permalink
improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcasalboni committed Aug 9, 2022
1 parent 78f6d9b commit 184f478
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lambda/utils.js
Expand Up @@ -25,7 +25,7 @@ module.exports.lambdaBaseCost = (region, architecture) => {
return this.baseCostForRegion(priceMap, region);
};

module.exports.buildAliasString = (baseAlias, onlyColdStarts = false, index = 0) => {
module.exports.buildAliasString = (baseAlias, onlyColdStarts, index) => {
let alias = baseAlias;
if (onlyColdStarts) {
alias += `-${index}`;
Expand Down
18 changes: 17 additions & 1 deletion test/unit/test-utils.js
Expand Up @@ -112,11 +112,27 @@ describe('Lambda Utils', () => {
});

describe('getLambdaPower', () => {
it('should return the memory value', async() => {
it('should return the power value and env vars', async() => {
const value = await utils.getLambdaPower('arn:aws:lambda:us-east-1:XXX:function:YYY');
expect(value.power).to.be(1024);
expect(value.envVars).to.be.an('object');
expect(value.envVars.TEST).to.be('OK');
});

it('should return the power value and env vars even when empty env', async() => {
AWS.remock('Lambda', 'getFunctionConfiguration', {
MemorySize: 1024,
State: 'Active',
LastUpdateStatus: 'Successful',
Architectures: ['x86_64'],
Environment: null, // this is null if no vars are set
});

const value = await utils.getLambdaPower('arn:aws:lambda:us-east-1:XXX:function:YYY');
expect(value.power).to.be(1024);
expect(value.envVars).to.be.an('object');
expect(value.envVars.TEST).to.be(undefined);
});
});

describe('verifyAliasExistance', () => {
Expand Down

0 comments on commit 184f478

Please sign in to comment.