mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
remove use of sls create in packaging tests
This commit is contained in:
parent
a8db8f4685
commit
bd5a4ac52e
14
tests/packaging-suite/handler.js
Normal file
14
tests/packaging-suite/handler.js
Normal 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 };
|
||||
};
|
||||
@ -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')));
|
||||
|
||||
10
tests/packaging-suite/serverless.yml
Normal file
10
tests/packaging-suite/serverless.yml
Normal file
@ -0,0 +1,10 @@
|
||||
service: aws-nodejs
|
||||
|
||||
provider:
|
||||
name: aws
|
||||
runtime: nodejs10.x
|
||||
|
||||
|
||||
functions:
|
||||
hello:
|
||||
handler: handler.hello
|
||||
Loading…
x
Reference in New Issue
Block a user