|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import {beforeEach, describe, expect, it, jest} from '@jest/globals'; |
| 17 | +import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals'; |
18 | 18 | import * as exec from '@actions/exec';
|
| 19 | +import path from 'path'; |
| 20 | +import osm = require('os'); |
19 | 21 |
|
20 | 22 | import {Docker} from '../src/docker';
|
21 | 23 |
|
22 | 24 | beforeEach(() => {
|
23 | 25 | jest.clearAllMocks();
|
24 | 26 | });
|
25 | 27 |
|
| 28 | +describe('configDir', () => { |
| 29 | + const originalEnv = process.env; |
| 30 | + beforeEach(() => { |
| 31 | + jest.resetModules(); |
| 32 | + process.env = { |
| 33 | + ...originalEnv, |
| 34 | + DOCKER_CONFIG: '/var/docker/config' |
| 35 | + }; |
| 36 | + }); |
| 37 | + afterEach(() => { |
| 38 | + process.env = originalEnv; |
| 39 | + }); |
| 40 | + it('returns default', async () => { |
| 41 | + process.env.DOCKER_CONFIG = ''; |
| 42 | + jest.spyOn(osm, 'homedir').mockImplementation(() => path.join('/tmp', 'home')); |
| 43 | + expect(Docker.configDir).toEqual(path.join('/tmp', 'home', '.docker')); |
| 44 | + }); |
| 45 | + it('returns from env', async () => { |
| 46 | + expect(Docker.configDir).toEqual('/var/docker/config'); |
| 47 | + }); |
| 48 | +}); |
| 49 | + |
26 | 50 | describe('isAvailable', () => {
|
27 | 51 | it('cli', () => {
|
28 | 52 | const execSpy = jest.spyOn(exec, 'getExecOutput');
|
29 |
| - Docker.isAvailable(); |
| 53 | + Docker.isAvailable; |
30 | 54 | // eslint-disable-next-line jest/no-standalone-expect
|
31 | 55 | expect(execSpy).toHaveBeenCalledWith(`docker`, undefined, {
|
32 | 56 | silent: true,
|
|
0 commit comments