Allow services with no functions #2267

This commit is contained in:
John McKim 2016-10-21 16:28:45 +10:00
parent dffd13acf4
commit fd1545d89d
2 changed files with 3 additions and 10 deletions

View File

@ -58,9 +58,6 @@ class Service {
if (!serverlessFile.provider) {
throw new SError('"provider" property is missing in serverless.yml');
}
if (!serverlessFile.functions) {
throw new SError('"functions" property is missing in serverless.yml');
}
if (typeof serverlessFile.provider !== 'object') {
const providerName = serverlessFile.provider;
@ -84,7 +81,7 @@ class Service {
that.custom = serverlessFile.custom;
that.plugins = serverlessFile.plugins;
that.resources = serverlessFile.resources;
that.functions = serverlessFile.functions;
that.functions = serverlessFile.functions || {};
if (serverlessFile.package) {
that.package.individually = serverlessFile.package.individually;

View File

@ -334,7 +334,7 @@ describe('Service', () => {
});
});
it('should throw error if functions property is missing', () => {
it('should not throw error if functions property is missing', () => {
const SUtils = new Utils();
const serverlessYml = {
service: 'service-name',
@ -347,11 +347,7 @@ describe('Service', () => {
serviceInstance = new Service(serverless);
return serviceInstance.load().then(() => {
// if we reach this, then no error was thrown as expected
// so make assertion fail intentionally to let us know something is wrong
expect(1).to.equal(2);
}).catch(e => {
expect(e.name).to.be.equal('ServerlessError');
expect(serverless.service.functions).to.deep.equal({});
});
});