|
1 | 1 | import * as fs from 'fs'; |
2 | 2 | import * as path from 'path'; |
3 | 3 | import * as semver from 'semver'; |
| 4 | +import * as exec from '@actions/exec'; |
4 | 5 |
|
5 | 6 | import * as buildx from '../src/buildx'; |
6 | 7 | import * as context from '../src/context'; |
7 | | -import * as docker from '../src/docker'; |
8 | 8 |
|
9 | 9 | const tmpNameSync = path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep); |
10 | 10 | const digest = 'sha256:bfb45ab72e46908183546477a08f8867fc40cebadd00af54b071b097aed127a9'; |
@@ -92,9 +92,26 @@ describe('isLocalOrTarExporter', () => { |
92 | 92 | ); |
93 | 93 | }); |
94 | 94 |
|
| 95 | +describe('isAvailable', () => { |
| 96 | + const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput'); |
| 97 | + buildx.isAvailable(); |
| 98 | + |
| 99 | + expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], { |
| 100 | + silent: true, |
| 101 | + ignoreReturnCode: true |
| 102 | + }); |
| 103 | +}); |
| 104 | + |
95 | 105 | describe('getVersion', () => { |
96 | 106 | async function isDaemonRunning() { |
97 | | - return await docker.isDaemonRunning(); |
| 107 | + return await exec |
| 108 | + .getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], { |
| 109 | + ignoreReturnCode: true, |
| 110 | + silent: true |
| 111 | + }) |
| 112 | + .then(res => { |
| 113 | + return !res.stdout.includes(' ') && res.exitCode == 0; |
| 114 | + }); |
98 | 115 | } |
99 | 116 | (isDaemonRunning() ? it : it.skip)( |
100 | 117 | 'valid', |
|
0 commit comments