diff --git a/lib/plugins/aws/deploy/lib/checkForChanges.test.js b/lib/plugins/aws/deploy/lib/checkForChanges.test.js index 7215edcb7..9d8e59242 100644 --- a/lib/plugins/aws/deploy/lib/checkForChanges.test.js +++ b/lib/plugins/aws/deploy/lib/checkForChanges.test.js @@ -13,6 +13,8 @@ const normalizeFiles = require('../../lib/normalizeFiles'); const AwsProvider = require('../../provider/awsProvider'); const AwsDeploy = require('../index'); const Serverless = require('../../../../Serverless'); +const runServerless = require('../../../../../tests/utils/run-serverless'); +const fixtures = require('../../../../../tests/fixtures'); // Configure chai chai.use(require('chai-as-promised')); @@ -996,3 +998,60 @@ describe('checkForChanges', () => { }); }); }); + +describe('checkForChanges #2', () => { + after(fixtures.cleanup); + it('Should recognize package.artifcat', () => + runServerless({ + cwd: fixtures.map.packageArtifact, + cliArgs: ['deploy'], + env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, + lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', + awsRequestStubMap: { + CloudFormation: { + describeStacks: {}, + describeStackResource: { + StackResourceDetail: { PhysicalResourceId: 'deployment-bucket' }, + }, + }, + Lambda: { + getFunction: { + Configuration: { + LastModified: '2020-05-20T15:34:16.494+0000', + }, + }, + }, + S3: { + headObject: { + Metadata: { filesha256: 'RRYyTm4Ri8mocpvx44pvas4JKLYtdJS3Z8MOlrZrDXA=' }, + }, + listObjectsV2: { + Contents: [ + { + Key: + 'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/artifact.zip', + LastModified: new Date(), + ETag: '"5102a4cf710cae6497dba9e61b85d0a4"', + Size: 356, + StorageClass: 'STANDARD', + }, + ], + }, + }, + STS: { + getCallerIdentity: { + ResponseMetadata: { RequestId: 'ffffffff-ffff-ffff-ffff-ffffffffffff' }, + UserId: 'XXXXXXXXXXXXXXXXXXXXX', + Account: '999999999999', + Arn: 'arn:aws:iam::999999999999:user/test', + }, + }, + }, + }).then(serverless => { + expect( + serverless.service.provider.compiledCloudFormationTemplate.Resources.FooLambdaFunction.Properties.Code.S3Key.endsWith( + '/artifact.zip' + ) + ).to.be.true; + })); +}); diff --git a/tests/fixtures/packageArtifact/artifact.zip b/tests/fixtures/packageArtifact/artifact.zip new file mode 100644 index 000000000..53781c530 Binary files /dev/null and b/tests/fixtures/packageArtifact/artifact.zip differ diff --git a/tests/fixtures/packageArtifact/serverless.yml b/tests/fixtures/packageArtifact/serverless.yml new file mode 100644 index 000000000..899e75bdc --- /dev/null +++ b/tests/fixtures/packageArtifact/serverless.yml @@ -0,0 +1,12 @@ +service: service +provider: + name: aws + +package: + artifact: artifact.zip + +functions: + foo: + handler: index.handler + other: + handler: index.handler