@@ -31,14 +31,27 @@ describe('runInfo', () => {
3131 sinon . restore ( )
3232 } )
3333
34+ it ( 'outputs valid JSON when docker is not installed (ENOENT)' , async ( ) => {
35+ sinon . stub ( fs , 'existsSync' ) . returns ( false )
36+ sinon . stub ( processUtils , 'runCommandWithOutput' ) . resolves ( { ok : false , reason : 'not-found' , stdout : '' , stderr : '' } )
37+
38+ const code = await infoCommand . runInfo ( { json : true } )
39+
40+ expect ( code ) . to . equal ( 0 )
41+ const parsed = JSON . parse ( stdout )
42+ expect ( parsed ) . to . have . nested . property ( 'runtime.uptimeSeconds' , null )
43+ expect ( stderr ) . to . equal ( '' )
44+ } )
45+
3446 it ( 'prints detected I2P hostnames as JSON' , async ( ) => {
3547 sinon . stub ( fs , 'existsSync' ) . callsFake ( ( target ) => String ( target ) . endsWith ( 'nostream.dat' ) )
3648 sinon
3749 . stub ( processUtils , 'runCommandWithOutput' )
3850 . onFirstCall ( )
39- . resolves ( { code : 1 , stdout : '' , stderr : '' } )
51+ . resolves ( { ok : true , code : 1 , stdout : '' , stderr : '' } )
4052 . onSecondCall ( )
4153 . resolves ( {
54+ ok : true ,
4255 code : 0 ,
4356 stdout : 'alphaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.b32.i2p\n' ,
4457 stderr : 'betabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.b32.i2p\n' ,
@@ -58,7 +71,7 @@ describe('runInfo', () => {
5871
5972 it ( 'prints a JSON error when I2P keys are missing' , async ( ) => {
6073 sinon . stub ( fs , 'existsSync' ) . returns ( false )
61- sinon . stub ( processUtils , 'runCommandWithOutput' ) . resolves ( { code : 1 , stdout : '' , stderr : '' } )
74+ sinon . stub ( processUtils , 'runCommandWithOutput' ) . resolves ( { ok : true , code : 1 , stdout : '' , stderr : '' } )
6275
6376 const code = await infoCommand . runInfo ( { i2pHostname : true , json : true } )
6477
@@ -77,9 +90,9 @@ describe('runInfo', () => {
7790 sinon
7891 . stub ( processUtils , 'runCommandWithOutput' )
7992 . onFirstCall ( )
80- . resolves ( { code : 1 , stdout : '' , stderr : '' } )
93+ . resolves ( { ok : true , code : 1 , stdout : '' , stderr : '' } )
8194 . onSecondCall ( )
82- . resolves ( { code : 0 , stdout : '' , stderr : '' } )
95+ . resolves ( { ok : true , code : 0 , stdout : '' , stderr : '' } )
8396
8497 const code = await infoCommand . runInfo ( { i2pHostname : true , json : true } )
8598
@@ -101,9 +114,9 @@ describe('runInfo', () => {
101114 sinon
102115 . stub ( processUtils , 'runCommandWithOutput' )
103116 . onFirstCall ( )
104- . resolves ( { code : 1 , stdout : '' , stderr : '' } )
117+ . resolves ( { ok : true , code : 1 , stdout : '' , stderr : '' } )
105118 . onSecondCall ( )
106- . resolves ( { code : 0 , stdout : '' , stderr : '' } )
119+ . resolves ( { ok : true , code : 0 , stdout : '' , stderr : '' } )
107120
108121 const code = await infoCommand . runInfo ( { i2pHostname : true } )
109122
0 commit comments