Skip to content

Commit 6d05d83

Browse files
authored
Merge pull request #6200 from mydiemho/myho/removeRegionDefaultFromBase
Remove default stage value in provider object
2 parents 11d2dea + e252259 commit 6d05d83

File tree

2 files changed

+109
-111
lines changed

2 files changed

+109
-111
lines changed

lib/classes/Service.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Service {
2121
this.serviceObject = null;
2222
this.provider = {
2323
stage: 'dev',
24-
region: 'us-east-1',
2524
variableSyntax: '\\${([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}',
2625
};
2726
this.custom = {};

lib/classes/Service.test.js

+109-110
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('Service', () => {
3131
expect(serviceInstance.serviceObject).to.be.equal(null);
3232
expect(serviceInstance.provider).to.deep.equal({
3333
stage: 'dev',
34-
region: 'us-east-1',
3534
variableSyntax: '\\${([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}',
3635
});
3736
expect(serviceInstance.custom).to.deep.equal({});
@@ -273,23 +272,23 @@ describe('Service', () => {
273272
serviceInstance = new Service(serverless);
274273

275274
return expect(serviceInstance.load()).to.eventually.be.fulfilled
276-
.then(() => {
277-
expect(serviceInstance.service).to.be.equal('new-service');
278-
expect(serviceInstance.provider.name).to.deep.equal('aws');
279-
expect(serviceInstance.provider.variableSyntax).to.equal(
280-
'\\${{([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}}'
281-
);
282-
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
283-
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
284-
expect(serviceInstance.resources.azure).to.deep.equal({});
285-
expect(serviceInstance.resources.google).to.deep.equal({});
286-
expect(serviceInstance.package.exclude.length).to.equal(1);
287-
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
288-
expect(serviceInstance.package.include.length).to.equal(1);
289-
expect(serviceInstance.package.include[0]).to.equal('include-me');
290-
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
291-
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
292-
});
275+
.then(() => {
276+
expect(serviceInstance.service).to.be.equal('new-service');
277+
expect(serviceInstance.provider.name).to.deep.equal('aws');
278+
expect(serviceInstance.provider.variableSyntax).to.equal(
279+
'\\${{([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}}'
280+
);
281+
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
282+
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
283+
expect(serviceInstance.resources.azure).to.deep.equal({});
284+
expect(serviceInstance.resources.google).to.deep.equal({});
285+
expect(serviceInstance.package.exclude.length).to.equal(1);
286+
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
287+
expect(serviceInstance.package.include.length).to.equal(1);
288+
expect(serviceInstance.package.include[0]).to.equal('include-me');
289+
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
290+
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
291+
});
293292
});
294293

295294
it('should load serverless.js from filesystem', () => {
@@ -329,23 +328,23 @@ describe('Service', () => {
329328
serviceInstance = new Service(serverless);
330329

331330
return expect(serviceInstance.load()).to.eventually.be.fulfilled
332-
.then(() => {
333-
expect(serviceInstance.service).to.be.equal('new-service');
334-
expect(serviceInstance.provider.name).to.deep.equal('aws');
335-
expect(serviceInstance.provider.variableSyntax).to.equal(
336-
'\\${{([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}}'
337-
);
338-
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
339-
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
340-
expect(serviceInstance.resources.azure).to.deep.equal({});
341-
expect(serviceInstance.resources.google).to.deep.equal({});
342-
expect(serviceInstance.package.exclude.length).to.equal(1);
343-
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
344-
expect(serviceInstance.package.include.length).to.equal(1);
345-
expect(serviceInstance.package.include[0]).to.equal('include-me');
346-
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
347-
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
348-
});
331+
.then(() => {
332+
expect(serviceInstance.service).to.be.equal('new-service');
333+
expect(serviceInstance.provider.name).to.deep.equal('aws');
334+
expect(serviceInstance.provider.variableSyntax).to.equal(
335+
'\\${{([ ~:a-zA-Z0-9._@\'",\\-\\/\\(\\)*]+?)}}'
336+
);
337+
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
338+
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
339+
expect(serviceInstance.resources.azure).to.deep.equal({});
340+
expect(serviceInstance.resources.google).to.deep.equal({});
341+
expect(serviceInstance.package.exclude.length).to.equal(1);
342+
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
343+
expect(serviceInstance.package.include.length).to.equal(1);
344+
expect(serviceInstance.package.include[0]).to.equal('include-me');
345+
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
346+
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
347+
});
349348
});
350349

351350
it('should load serverless.js from filesystem', () => {
@@ -385,23 +384,23 @@ describe('Service', () => {
385384
serviceInstance = new Service(serverless);
386385

387386
return expect(serviceInstance.load()).to.eventually.be.fulfilled
388-
.then(() => {
389-
expect(serviceInstance.service).to.be.equal('new-service');
390-
expect(serviceInstance.provider.name).to.deep.equal('aws');
391-
expect(serviceInstance.provider.variableSyntax).to.equal(
392-
'\\${{([ ~:a-zA-Z0-9._\'",\\-\\/\\(\\)]+?)}}'
393-
);
394-
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
395-
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
396-
expect(serviceInstance.resources.azure).to.deep.equal({});
397-
expect(serviceInstance.resources.google).to.deep.equal({});
398-
expect(serviceInstance.package.exclude.length).to.equal(1);
399-
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
400-
expect(serviceInstance.package.include.length).to.equal(1);
401-
expect(serviceInstance.package.include[0]).to.equal('include-me');
402-
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
403-
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
404-
});
387+
.then(() => {
388+
expect(serviceInstance.service).to.be.equal('new-service');
389+
expect(serviceInstance.provider.name).to.deep.equal('aws');
390+
expect(serviceInstance.provider.variableSyntax).to.equal(
391+
'\\${{([ ~:a-zA-Z0-9._\'",\\-\\/\\(\\)]+?)}}'
392+
);
393+
expect(serviceInstance.plugins).to.deep.equal(['testPlugin']);
394+
expect(serviceInstance.resources.aws).to.deep.equal({ resourcesProp: 'value' });
395+
expect(serviceInstance.resources.azure).to.deep.equal({});
396+
expect(serviceInstance.resources.google).to.deep.equal({});
397+
expect(serviceInstance.package.exclude.length).to.equal(1);
398+
expect(serviceInstance.package.exclude[0]).to.equal('exclude-me');
399+
expect(serviceInstance.package.include.length).to.equal(1);
400+
expect(serviceInstance.package.include[0]).to.equal('include-me');
401+
expect(serviceInstance.package.artifact).to.equal('some/path/foo.zip');
402+
expect(serviceInstance.package.excludeDevDependencies).to.equal(undefined);
403+
});
405404
});
406405

407406
it('should throw error if serverless.js exports invalid config', () => {
@@ -460,10 +459,10 @@ describe('Service', () => {
460459
serviceInstance = new Service(serverless);
461460

462461
return expect(serviceInstance.load()).to.eventually.be.fulfilled
463-
.then(() => {
464-
// YAML should have been loaded instead of JSON
465-
expect(serviceInstance.service).to.be.equal('YAML service');
466-
});
462+
.then(() => {
463+
// YAML should have been loaded instead of JSON
464+
expect(serviceInstance.service).to.be.equal('YAML service');
465+
});
467466
});
468467

469468
it('should reject when the service name is missing', () => {
@@ -502,10 +501,10 @@ describe('Service', () => {
502501
serviceInstance = new Service(serverless);
503502

504503
return expect(serviceInstance.load()).to.eventually.be.fulfilled
505-
.then(() => {
506-
expect(serviceInstance.service).to.equal('my-service');
507-
expect(serviceInstance.serviceObject).to.deep.equal(serverlessYaml.service);
508-
});
504+
.then(() => {
505+
expect(serviceInstance.service).to.equal('my-service');
506+
expect(serviceInstance.serviceObject).to.deep.equal(serverlessYaml.service);
507+
});
509508
});
510509

511510
it('should support Serverless file with a non-aws provider', () => {
@@ -528,18 +527,18 @@ describe('Service', () => {
528527
serviceInstance = new Service(serverless);
529528

530529
return expect(serviceInstance.load()).to.eventually.be.fulfilled
531-
.then(() => {
532-
serviceInstance.setFunctionNames();
533-
const expectedFunc = {
534-
functionA: {
535-
name: 'customFunctionName',
536-
events: [],
537-
},
538-
};
539-
expect(serviceInstance.service).to.be.equal('my-service');
540-
expect(serviceInstance.provider.name).to.deep.equal('openwhisk');
541-
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
542-
});
530+
.then(() => {
531+
serviceInstance.setFunctionNames();
532+
const expectedFunc = {
533+
functionA: {
534+
name: 'customFunctionName',
535+
events: [],
536+
},
537+
};
538+
expect(serviceInstance.service).to.be.equal('my-service');
539+
expect(serviceInstance.provider.name).to.deep.equal('openwhisk');
540+
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
541+
});
543542
});
544543

545544
it('should support Serverless file with a .yaml extension', () => {
@@ -562,18 +561,18 @@ describe('Service', () => {
562561
serviceInstance = new Service(serverless);
563562

564563
return expect(serviceInstance.load()).to.eventually.be.fulfilled
565-
.then(() => {
566-
serviceInstance.setFunctionNames();
567-
const expectedFunc = {
568-
functionA: {
569-
name: 'customFunctionName',
570-
events: [],
571-
},
572-
};
573-
expect(serviceInstance.service).to.be.equal('my-service');
574-
expect(serviceInstance.provider.name).to.deep.equal('aws');
575-
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
576-
});
564+
.then(() => {
565+
serviceInstance.setFunctionNames();
566+
const expectedFunc = {
567+
functionA: {
568+
name: 'customFunctionName',
569+
events: [],
570+
},
571+
};
572+
expect(serviceInstance.service).to.be.equal('my-service');
573+
expect(serviceInstance.provider.name).to.deep.equal('aws');
574+
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
575+
});
577576
});
578577

579578
it('should support Serverless file with a .yml extension', () => {
@@ -594,18 +593,18 @@ describe('Service', () => {
594593
serviceInstance = new Service(serverless);
595594

596595
return expect(serviceInstance.load({ stage: 'dev' })).to.eventually.be.fulfilled
597-
.then(() => {
598-
serviceInstance.setFunctionNames();
599-
const expectedFunc = {
600-
functionA: {
601-
name: 'my-service-dev-functionA',
602-
events: [],
603-
},
604-
};
605-
expect(serviceInstance.service).to.be.equal('my-service');
606-
expect(serviceInstance.provider.name).to.deep.equal('aws');
607-
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
608-
});
596+
.then(() => {
597+
serviceInstance.setFunctionNames();
598+
const expectedFunc = {
599+
functionA: {
600+
name: 'my-service-dev-functionA',
601+
events: [],
602+
},
603+
};
604+
expect(serviceInstance.service).to.be.equal('my-service');
605+
expect(serviceInstance.provider.name).to.deep.equal('aws');
606+
expect(serviceInstance.functions).to.deep.equal(expectedFunc);
607+
});
609608
});
610609

611610
it('should reject if service property is missing', () => {
@@ -698,15 +697,15 @@ describe('Service', () => {
698697
serviceInstance = new Service(serverless);
699698

700699
return expect(serviceInstance.load()).to.eventually.be.fulfilled
701-
.then(() => {
702-
// populate variables in service configuration
703-
serverless.variables.populateService();
700+
.then(() => {
701+
// populate variables in service configuration
702+
serverless.variables.populateService();
704703

705-
// validate the service configuration, now that variables are loaded
706-
serviceInstance.validate();
704+
// validate the service configuration, now that variables are loaded
705+
serviceInstance.validate();
707706

708-
expect(serviceInstance.functions).to.deep.equal({});
709-
});
707+
expect(serviceInstance.functions).to.deep.equal({});
708+
});
710709
});
711710
});
712711

@@ -736,11 +735,11 @@ describe('Service', () => {
736735
serverless.service = new Service(serverless);
737736

738737
return expect(serverless.service.load()).to.eventually.be.fulfilled
739-
.then(() => {
740-
// validate the service configuration, now that variables are loaded
741-
expect(() => serverless.service.validate())
742-
.to.throw('Events for "functionA" must be an array, not an string');
743-
});
738+
.then(() => {
739+
// validate the service configuration, now that variables are loaded
740+
expect(() => serverless.service.validate())
741+
.to.throw('Events for "functionA" must be an array, not an string');
742+
});
744743
});
745744

746745
describe('stage name validation', () => {
@@ -754,7 +753,7 @@ describe('Service', () => {
754753
}
755754

756755
it(`should not throw an error if http event is absent and
757-
stage contains only alphanumeric, underscore and hyphen`, function () {
756+
stage contains only alphanumeric, underscore and hyphen`, function () {
758757
this.timeout(10000); // Occasionally times out with default settings
759758
const SUtils = new Utils();
760759
const serverlessYml = {
@@ -780,7 +779,7 @@ describe('Service', () => {
780779
});
781780

782781
it(`should not throw an error after variable population if http event is present and
783-
the populated stage contains only alphanumeric, underscore and hyphen`, () => {
782+
the populated stage contains only alphanumeric, underscore and hyphen`, () => {
784783
const SUtils = new Utils();
785784
const serverlessYml = {
786785
service: 'new-service',

0 commit comments

Comments
 (0)