From 06cf6df2e6c8cd330b480cfa934082f7d3eb946f Mon Sep 17 00:00:00 2001 From: Frank Schmid Date: Thu, 26 Oct 2017 12:14:10 +0200 Subject: [PATCH] More tests to increase coverage --- lib/plugins/aws/deployFunction/index.test.js | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/plugins/aws/deployFunction/index.test.js b/lib/plugins/aws/deployFunction/index.test.js index 7a1ada4a9..886d61fdd 100644 --- a/lib/plugins/aws/deployFunction/index.test.js +++ b/lib/plugins/aws/deployFunction/index.test.js @@ -1,6 +1,6 @@ 'use strict'; -const expect = require('chai').expect; +const chai = require('chai'); const sinon = require('sinon'); const path = require('path'); const fs = require('fs'); @@ -9,6 +9,11 @@ const AwsProvider = require('../provider/awsProvider'); const Serverless = require('../../../Serverless'); const testUtils = require('../../../../tests/utils'); +chai.use(require('chai-as-promised')); +chai.use(require('sinon-chai')); + +const expect = chai.expect; + describe('AwsDeployFunction', () => { let AwsDeployFunction; let serverless; @@ -292,7 +297,14 @@ describe('AwsDeployFunction', () => { options.functionObj = { name: 'first', description: 'change', - vpc: undefined, + vpc: { + securityGroupIds: ['xxxxx', { + ref: 'myVPCRef', + }], + subnetIds: ['xxxxx', { + ref: 'myVPCRef', + }], + }, environment: { myvar: 'this is my var', myref: { @@ -318,6 +330,23 @@ describe('AwsDeployFunction', () => { }); }); + it('should do nothing if only references are in', () => { + options.functionObj = { + name: 'first', + environment: { + myvar: 'this is my var', + myref: { + ref: 'aCFReference', + }, + }, + }; + + awsDeployFunction.options = options; + + return expect(awsDeployFunction.updateFunctionConfiguration()).to.be.fulfilled + .then(() => expect(updateFunctionConfigurationStub).to.not.be.called); + }); + it('should fail when using invalid characters in environment variable', () => { options.functionObj = { name: 'first',