11var expect = require ( 'chai' ) . expect
22
3+ var fs = require ( 'fs' )
4+
35var ConfigReader = require ( './configReader' )
46
57describe ( 'Config Reader module' , function ( ) {
@@ -187,6 +189,25 @@ describe('Config Reader module', function () {
187189 delete process . env . VCAP_SERVICES
188190 } )
189191
192+ it ( 'loads VM specific config (LXC/Docker)' , function ( ) {
193+ this . sandbox . stub ( fs , 'readFileSync' , function ( ) {
194+ return '11:memory:/docker'
195+ } )
196+
197+ var configReader = ConfigReader . create ( {
198+ serviceName : 'test' ,
199+ reporter : 'dummy' ,
200+ collectorApiUrl : 'http://c.a.b' ,
201+ apiKey : testApiToken
202+ } )
203+
204+ this . sandbox . stub ( configReader , '_getDefaultConfig' , function ( ) {
205+ return { configPath : 'default' }
206+ } )
207+
208+ expect ( configReader . getConfig ( ) . isRunningInVm ) . to . eql ( true )
209+ } )
210+
190211 it ( 'can find config file by default config' , function ( ) {
191212 var configReader = ConfigReader . create ( {
192213 serviceName : 'test' ,
@@ -255,16 +276,11 @@ describe('Config Reader module', function () {
255276
256277 it ( 'throws readable error on loading invalid config file' , function ( ) {
257278 var configReader = ConfigReader . create ( { serviceName : 'test' , reporter : 'dummy' , configPath : 'test' } )
258- var readConfigFileStub = this . sandbox . stub ( configReader , '_readConfigFile' , function ( ) {
259- // simulates an error
260- throw new Error ( )
261- } )
262279
263280 try {
264281 configReader . getConfig ( )
265282 } catch ( ex ) {
266283 expect ( ex ) . to . be . eql ( new Error ( 'Invalid trace.config.js configuration file' ) )
267- expect ( readConfigFileStub ) . to . have . been . calledOnce
268284 return
269285 }
270286
@@ -287,6 +303,18 @@ describe('Config Reader module', function () {
287303 this . sandbox . stub ( configReader , '_readConfigFile' , function ( ) {
288304 return { ignoreHeaders : wellformed }
289305 } )
306+
307+ this . sandbox . stub ( configReader , '_getDefaultConfig' , function ( ) {
308+ return {
309+ test : 'default' ,
310+ collectorApiUrl : 'http://c.a.b'
311+ }
312+ } )
313+
314+ this . sandbox . stub ( fs , 'statSync' , function ( ) {
315+ return { }
316+ } )
317+
290318 try {
291319 var config = configReader . getConfig ( )
292320 expect ( config . ignoreHeaders ) . to . eql ( wellformed )
0 commit comments