@@ -137,6 +137,43 @@ test('config loads from datacenter file', withFixtures(__dirname, {
137137 assert . end ( ) ;
138138} ) ) ;
139139
140+ test ( 'config loads from dcValue' , withFixtures ( __dirname , {
141+ 'config' : {
142+ 'common.json' : JSON . stringify ( {
143+ a : 'a' ,
144+ b : {
145+ c : 'c' ,
146+ d : 'd'
147+ }
148+ } ) ,
149+ 'production.json' : JSON . stringify ( {
150+ b : {
151+ c : 'c2'
152+ }
153+ } ) ,
154+ 'production.peak1.json' : JSON . stringify ( {
155+ a : 'a3'
156+ } )
157+ }
158+ } , function ( assert ) {
159+ var env = {
160+ 'NODE_ENV' : 'production'
161+ } ;
162+
163+ var config = fetchConfig ( __dirname , {
164+ env : env ,
165+ dcValue : 'peak1'
166+ } ) ;
167+
168+ assert . equal ( config . get ( 'datacenter' ) , 'peak1' ) ;
169+ assert . equal ( config . get ( 'a' ) , 'a3' ) ;
170+ assert . equal ( config . get ( 'b.c' ) , 'c2' ) ;
171+ assert . equal ( config . get ( 'b.d' ) , 'd' ) ;
172+ assert . deepEqual ( config . get ( 'b' ) , { c : 'c2' , d : 'd' } ) ;
173+
174+ assert . end ( ) ;
175+ } ) ) ;
176+
140177test ( 'config reads a datacenter file' , withFixtures ( __dirname , {
141178 datacenter : 'peak1'
142179} , function ( assert ) {
@@ -201,7 +238,7 @@ test('will load from --config', withFixtures(__dirname, {
201238 assert . end ( ) ;
202239} ) ) ;
203240
204- test ( 'no opts.dc in production' , function ( assert ) {
241+ test ( 'no opts.dcValue in production' , function ( assert ) {
205242 var err = catchFn ( function ( ) {
206243 fetchConfig ( __dirname , {
207244 env : { NODE_ENV : 'production' }
@@ -210,8 +247,8 @@ test('no opts.dc in production', function (assert) {
210247
211248 assert . ok ( err ) ;
212249 assert . equal ( err . type , 'datacenter.option.required' ) ;
213- assert . ok ( / e x p e c t e d ` o p t s .d c ` / . test ( err . message ) ) ;
214- assert . ok ( / ` o p t s .d c ` i s n o t o p t i o n a l / . test ( err . message ) ) ;
250+ assert . ok ( / e x p e c t e d ` o p t s .d c V a l u e ` / . test ( err . message ) ) ;
251+ assert . ok ( / ` o p t s .d c V a l u e ` i s n o t o p t i o n a l / . test ( err . message ) ) ;
215252
216253 assert . end ( ) ;
217254} ) ;
0 commit comments