11import fs = require( 'fs' ) ;
2- import * as docker from '../src/docker' ;
32import * as buildx from '../src/buildx' ;
43import * as path from 'path' ;
54import * as os from 'os' ;
65import * as semver from 'semver' ;
76import * as exec from '@actions/exec' ;
87
8+ describe ( 'isAvailable' , ( ) => {
9+ const execSpy : jest . SpyInstance = jest . spyOn ( exec , 'getExecOutput' ) ;
10+ buildx . isAvailable ( ) ;
11+
12+ expect ( execSpy ) . toHaveBeenCalledWith ( `docker` , [ 'buildx' ] , {
13+ silent : true ,
14+ ignoreReturnCode : true
15+ } ) ;
16+ } ) ;
17+
918describe ( 'getVersion' , ( ) => {
10- it ( 'valid' , async ( ) => {
11- await exec . exec ( 'docker' , [ 'buildx' , 'version' ] ) ;
12- const version = await buildx . getVersion ( ) ;
13- console . log ( `version: ${ version } ` ) ;
14- expect ( semver . valid ( version ) ) . not . toBeNull ( ) ;
15- } , 100000 ) ;
19+ async function isDaemonRunning ( ) {
20+ return await exec
21+ . getExecOutput ( `docker` , [ 'version' , '--format' , '{{.Server.Os}}' ] , {
22+ ignoreReturnCode : true ,
23+ silent : true
24+ } )
25+ . then ( res => {
26+ return ! res . stdout . includes ( ' ' ) && res . exitCode == 0 ;
27+ } ) ;
28+ }
29+ ( isDaemonRunning ( ) ? it : it . skip ) (
30+ 'valid' ,
31+ async ( ) => {
32+ const version = await buildx . getVersion ( ) ;
33+ console . log ( `version: ${ version } ` ) ;
34+ expect ( semver . valid ( version ) ) . not . toBeNull ( ) ;
35+ } ,
36+ 100000
37+ ) ;
1638} ) ;
1739
1840describe ( 'parseVersion' , ( ) => {
@@ -27,7 +49,14 @@ describe('parseVersion', () => {
2749
2850describe ( 'inspect' , ( ) => {
2951 async function isDaemonRunning ( ) {
30- return await docker . isDaemonRunning ( ) ;
52+ return await exec
53+ . getExecOutput ( `docker` , [ 'version' , '--format' , '{{.Server.Os}}' ] , {
54+ ignoreReturnCode : true ,
55+ silent : true
56+ } )
57+ . then ( res => {
58+ return ! res . stdout . includes ( ' ' ) && res . exitCode == 0 ;
59+ } ) ;
3160 }
3261 ( isDaemonRunning ( ) ? it : it . skip ) (
3362 'valid' ,
0 commit comments