11import ContainerIsNotPresentError
22 from '../../../../src/docker/errors/ContainerIsNotPresentError.js' ;
3+ import DockerComposeError from '../../../../src/docker/errors/DockerComposeError.js' ;
34import providers from '../../../../src/status/providers.js' ;
45import determineStatus from '../../../../src/status/determineStatus.js' ;
56import getConfigMock from '../../../../src/test/mock/getConfigMock.js' ;
@@ -73,7 +74,8 @@ describe('getPlatformScopeFactory', () => {
7374 } ,
7475 } ) ;
7576 mockDockerCompose . isServiceRunning . returns ( true ) ;
76- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
77+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci status' ) . resolves ( { exitCode : 0 , out : '' } ) ;
78+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . resolves ( { exitCode : 0 , out : '1.4.1' } ) ;
7779 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
7880
7981 const mockStatus = {
@@ -121,6 +123,7 @@ describe('getPlatformScopeFactory', () => {
121123 drive : {
122124 dockerStatus : DockerStatusEnum . running ,
123125 serviceStatus : ServiceStatusEnum . up ,
126+ version : '1.4.1' ,
124127 } ,
125128 } ;
126129
@@ -147,7 +150,7 @@ describe('getPlatformScopeFactory', () => {
147150 } ,
148151 } ) ;
149152 mockDockerCompose . isServiceRunning . returns ( true ) ;
150- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
153+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . resolves ( { exitCode : 0 , out : '1.4.1 ' } ) ;
151154 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
152155
153156 const mockStatus = {
@@ -195,6 +198,7 @@ describe('getPlatformScopeFactory', () => {
195198 drive : {
196199 dockerStatus : DockerStatusEnum . running ,
197200 serviceStatus : ServiceStatusEnum . up ,
201+ version : '1.4.1' ,
198202 } ,
199203 } ;
200204
@@ -212,7 +216,6 @@ describe('getPlatformScopeFactory', () => {
212216
213217 it ( 'should return empty scope if error during request to core' , async ( ) => {
214218 mockRpcClient . mnsync . withArgs ( 'status' ) . throws ( new Error ( ) ) ;
215- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
216219 mockDockerCompose . isServiceRunning . returns ( true ) ;
217220 mockDetermineDockerStatus . withArgs ( mockDockerCompose , config , 'drive_tenderdash' )
218221 . returns ( DockerStatusEnum . running ) ;
@@ -268,7 +271,7 @@ describe('getPlatformScopeFactory', () => {
268271 } ,
269272 } ,
270273 } ) ;
271- mockDockerCompose . execCommand . returns ( { exitCode : 1 , out : '' } ) ;
274+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . resolves ( { exitCode : 0 , out : '1.4.1 ' } ) ;
272275 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
273276
274277 const expectedScope = {
@@ -300,6 +303,7 @@ describe('getPlatformScopeFactory', () => {
300303 drive : {
301304 dockerStatus : DockerStatusEnum . running ,
302305 serviceStatus : ServiceStatusEnum . wait_for_core ,
306+ version : '1.4.1' ,
303307 } ,
304308 } ;
305309
@@ -324,7 +328,7 @@ describe('getPlatformScopeFactory', () => {
324328 . returns ( DockerStatusEnum . running ) ;
325329 mockDetermineDockerStatus . withArgs ( mockDockerCompose , config , 'drive_abci' )
326330 . returns ( DockerStatusEnum . running ) ;
327- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
331+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . resolves ( { exitCode : 0 , out : '1.4.1 ' } ) ;
328332 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
329333
330334 const expectedScope = {
@@ -356,6 +360,7 @@ describe('getPlatformScopeFactory', () => {
356360 drive : {
357361 dockerStatus : DockerStatusEnum . running ,
358362 serviceStatus : ServiceStatusEnum . up ,
363+ version : '1.4.1' ,
359364 } ,
360365 } ;
361366
@@ -380,8 +385,11 @@ describe('getPlatformScopeFactory', () => {
380385 . returns ( DockerStatusEnum . running ) ;
381386 mockDetermineDockerStatus . withArgs ( mockDockerCompose , config , 'drive_abci' )
382387 . throws ( new ContainerIsNotPresentError ( 'drive_abci' ) ) ;
383- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
384388 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
389+ const error = new DockerComposeError ( {
390+ exitCode : 1 ,
391+ } ) ;
392+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . rejects ( error ) ;
385393
386394 const mockStatus = {
387395 node_info : {
@@ -434,6 +442,7 @@ describe('getPlatformScopeFactory', () => {
434442 drive : {
435443 dockerStatus : DockerStatusEnum . not_started ,
436444 serviceStatus : ServiceStatusEnum . stopped ,
445+ version : null ,
437446 } ,
438447 } ;
439448
@@ -454,7 +463,8 @@ describe('getPlatformScopeFactory', () => {
454463 mockDockerCompose . isServiceRunning
455464 . withArgs ( config , 'drive_tenderdash' )
456465 . returns ( true ) ;
457- mockDockerCompose . execCommand . returns ( { exitCode : 0 , out : '' } ) ;
466+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci status' ) . resolves ( { exitCode : 0 , out : '' } ) ;
467+ mockDockerCompose . execCommand . withArgs ( config , 'drive_abci' , 'drive-abci version' ) . resolves ( { exitCode : 0 , out : '1.4.1' } ) ;
458468 mockDetermineDockerStatus . returns ( DockerStatusEnum . running ) ;
459469 mockMNOWatchProvider . returns ( Promise . resolve ( 'OPEN' ) ) ;
460470 mockFetch . returns ( Promise . reject ( new Error ( 'FetchError' ) ) ) ;
@@ -488,6 +498,7 @@ describe('getPlatformScopeFactory', () => {
488498 drive : {
489499 dockerStatus : DockerStatusEnum . running ,
490500 serviceStatus : ServiceStatusEnum . up ,
501+ version : '1.4.1' ,
491502 } ,
492503 } ;
493504
0 commit comments