cleanup temp dir after each test when installing buildx

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-02-17 20:00:56 +01:00
parent 2abe456e6b
commit 12e3bd7469

View File

@@ -14,26 +14,31 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, expect, it, jest, test, beforeEach} from '@jest/globals'; import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as rimraf from 'rimraf';
import osm = require('os'); import osm = require('os');
import {Install} from '../../src/buildx/install'; import {Install} from '../../src/buildx/install';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
afterEach(function () {
rimraf.sync(tmpDir);
});
describe('install', () => { describe('install', () => {
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-install-jest').split(path.sep).join(path.posix.sep);
// prettier-ignore // prettier-ignore
test.each([ test.each([
['v0.4.1', false], ['v0.9.1', false],
['latest', false], ['latest', false],
['v0.4.1', true], ['v0.9.1', true],
['latest', true] ['latest', true]
])( ])(
'acquires %p of buildx (standalone: %p)', async (version, standalone) => { 'acquires %p of buildx (standalone: %p)', async (version, standalone) => {