remove use of sls create in packaging tests

This commit is contained in:
Daniel Schep 2019-05-22 08:04:36 -04:00
parent a8db8f4685
commit bd5a4ac52e
3 changed files with 34 additions and 5 deletions

View File

@ -0,0 +1,14 @@
'use strict';
module.exports.hello = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}, null, 2),
};
// Use this code if you don't use the http event with the LAMBDA-PROXY integration
// return { message: 'Go Serverless v1.0! Your function executed successfully!', event };
};

View File

@ -17,7 +17,8 @@ describe('Integration test - Packaging', () => {
it('packages the default aws template correctly in the zip', () => {
const templateName = 'aws-nodejs';
execSync(`${serverlessExec} create --template ${templateName}`, { cwd });
fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml'))
fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js'))
execSync(`${serverlessExec} package`, { cwd });
return testUtils.listZipFiles(path.join(cwd, '.serverless/aws-nodejs.zip'))
.then(zipfiles => {
@ -27,7 +28,8 @@ describe('Integration test - Packaging', () => {
it('packages the default aws template with an npm dep correctly in the zip', () => {
const templateName = 'aws-nodejs';
execSync(`${serverlessExec} create --template ${templateName}`, { cwd });
fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml'))
fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js'))
execSync('npm init --yes', { cwd });
execSync('npm i lodash', { cwd });
execSync(`${serverlessExec} package`, { cwd });
@ -43,7 +45,8 @@ describe('Integration test - Packaging', () => {
it('doesn\'t package a dev dependency in the zip', () => {
const templateName = 'aws-nodejs';
execSync(`${serverlessExec} create --template ${templateName}`, { cwd });
fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml'))
fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js'))
execSync('npm init --yes', { cwd });
execSync('npm i --save-dev lodash', { cwd });
execSync(`${serverlessExec} package`, { cwd });
@ -59,7 +62,8 @@ describe('Integration test - Packaging', () => {
it('ignores package json files per ignore directive in the zip', () => {
const templateName = 'aws-nodejs';
execSync(`${serverlessExec} create --template ${templateName}`, { cwd });
fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml'))
fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js'))
execSync('npm init --yes', { cwd });
execSync('echo \'package: {exclude: ["package*.json"]}\' >> serverless.yml', { cwd });
execSync('npm i lodash', { cwd });
@ -84,7 +88,8 @@ describe('Integration test - Packaging', () => {
it('creates the correct default function resource in cfn template', () => {
const templateName = 'aws-nodejs';
execSync(`${serverlessExec} create --template ${templateName}`, { cwd });
fs.copyFileSync(path.join(__dirname, 'serverless.yml'), path.join(cwd, 'serverless.yml'))
fs.copyFileSync(path.join(__dirname, 'handler.js'), path.join(cwd, 'handler.js'))
execSync(`${serverlessExec} package`, { cwd });
const cfnTemplate = JSON.parse(fs.readFileSync(path.join(
cwd, '.serverless/cloudformation-template-update-stack.json')));

View File

@ -0,0 +1,10 @@
service: aws-nodejs
provider:
name: aws
runtime: nodejs10.x
functions:
hello:
handler: handler.hello