File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,19 @@ const BbPromise = require('bluebird');
5
5
6
6
module . exports = {
7
7
setDefaults ( ) {
8
- this . options . stage = _ . get ( this , 'options.stage' )
9
- || 'dev' ;
10
- this . options . runtime = _ . get ( this , 'options.runtime' )
11
- || 'nodejs8' ;
8
+ this . options . stage = _ . get ( this , 'options.stage' ) || 'dev' ;
9
+ this . options . runtime = _ . get ( this , 'options.runtime' ) || 'nodejs8' ;
12
10
13
11
// serverless framework is hard-coding us-east-1 region from aws
14
12
// this is temporary fix for multiple regions
15
- const region = _ . get ( this , 'options.region' )
16
- || _ . get ( this , 'serverless.service.provider.region' ) ;
13
+ let region = _ . get ( this , 'options.region' ) || _ . get ( this , 'serverless.service.provider.region' ) ;
17
14
18
- this . options . region = ( ! region || region === 'us-east-1' )
19
- ? 'us-central1' : region ;
15
+ if ( region === 'us-east-1' ) {
16
+ region = 'us-central1' ;
17
+ }
18
+
19
+ this . options . region = region ;
20
+ this . serverless . service . provider . region = region ;
20
21
21
22
return BbPromise . resolve ( ) ;
22
23
} ,
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ describe('Utils', () => {
13
13
serverless = new Serverless ( ) ;
14
14
serverless . setProvider ( 'google' , new GoogleProvider ( serverless ) ) ;
15
15
googleCommand = new GoogleCommand ( serverless , { } , setDefaults ) ;
16
+ // mocking the standard value passed in from Serverless here
17
+ googleCommand . serverless . service . provider = {
18
+ region : 'us-east-1' ,
19
+ } ;
16
20
} ) ;
17
21
18
22
describe ( '#setDefaults()' , ( ) => {
@@ -45,5 +49,10 @@ describe('Utils', () => {
45
49
expect ( googleCommand . options . region ) . toEqual ( 'my-region' ) ;
46
50
} ) ;
47
51
} ) ;
52
+
53
+ it ( 'shoud default to the us-central1 region when no region is provided' , ( ) => googleCommand
54
+ . setDefaults ( ) . then ( ( ) => {
55
+ expect ( googleCommand . options . region ) . toEqual ( 'us-central1' ) ;
56
+ } ) ) ;
48
57
} ) ;
49
58
} ) ;
You can’t perform that action at this time.
0 commit comments