|
| 1 | +/** |
| 2 | + * Copyright 2023 actions-toolkit authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import {describe, expect, jest, test, beforeEach, afterEach} from '@jest/globals'; |
| 18 | +import * as fs from 'fs'; |
| 19 | +import * as path from 'path'; |
| 20 | +import * as rimraf from 'rimraf'; |
| 21 | +import osm = require('os'); |
| 22 | + |
| 23 | +import {Install} from '../../src/docker/install'; |
| 24 | + |
| 25 | +// prettier-ignore |
| 26 | +const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest'); |
| 27 | + |
| 28 | +beforeEach(() => { |
| 29 | + jest.clearAllMocks(); |
| 30 | +}); |
| 31 | + |
| 32 | +afterEach(function () { |
| 33 | + rimraf.sync(tmpDir); |
| 34 | +}); |
| 35 | + |
| 36 | +describe('download', () => { |
| 37 | + // prettier-ignore |
| 38 | + test.each([ |
| 39 | + ['19.03.6', 'linux'], |
| 40 | + ['20.10.22', 'linux'], |
| 41 | + ['20.10.22', 'darwin'], |
| 42 | + ['20.10.22', 'win32'], |
| 43 | + ])( |
| 44 | + 'acquires %p of docker (%s)', async (version, platformOS) => { |
| 45 | + jest.spyOn(osm, 'platform').mockImplementation(() => platformOS); |
| 46 | + const install = new Install(); |
| 47 | + const toolPath = await install.download(version); |
| 48 | + expect(fs.existsSync(toolPath)).toBe(true); |
| 49 | + }, 100000); |
| 50 | +}); |
0 commit comments