switch from Jest to Vitest
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {jest} from '@jest/globals';
|
||||
import {vi} from 'vitest';
|
||||
import os from 'os';
|
||||
|
||||
export const mockPlatform = (platform: NodeJS.Platform) => {
|
||||
return jest.spyOn(os, 'platform').mockImplementation(() => platform);
|
||||
return vi.spyOn(os, 'platform').mockImplementation(() => platform);
|
||||
};
|
||||
|
||||
export const mockArch = (arch: string) => {
|
||||
return jest.spyOn(os, 'arch').mockImplementation(() => arch);
|
||||
return vi.spyOn(os, 'arch').mockImplementation(() => arch);
|
||||
};
|
||||
|
||||
export const mockHomedir = (dir: string) => {
|
||||
return jest.spyOn(os, 'homedir').mockImplementation(() => dir);
|
||||
return vi.spyOn(os, 'homedir').mockImplementation(() => dir);
|
||||
};
|
||||
|
||||
38
__tests__/.setup/list-itg-tests.mjs
Normal file
38
__tests__/.setup/list-itg-tests.mjs
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const testsRoot = path.resolve('__tests__');
|
||||
const results = [];
|
||||
|
||||
const walk = dir => {
|
||||
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
walk(fullPath);
|
||||
continue;
|
||||
}
|
||||
if (entry.isFile() && entry.name.endsWith('.test.itg.ts')) {
|
||||
results.push(fullPath.replaceAll(path.sep, '/'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
walk(testsRoot);
|
||||
results.sort((a, b) => a.localeCompare(b));
|
||||
process.stdout.write(`${results.join('\n')}\n`);
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2024 actions-toolkit authors
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,15 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const fs = require('fs');
|
||||
import {vi} from 'vitest';
|
||||
|
||||
module.exports = results => {
|
||||
const allSkipped = results.testResults.every(result => result.skipped);
|
||||
if (allSkipped) {
|
||||
console.log('All tests were skipped!');
|
||||
fs.mkdirSync('./coverage', {recursive: true});
|
||||
fs.closeSync(fs.openSync('./coverage/allSkipped.txt', 'w'));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
vi.mock('@actions/github');
|
||||
36
__tests__/.setup/setup.unit.ts
Normal file
36
__tests__/.setup/setup.unit.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2026 actions-toolkit authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import {vi} from 'vitest';
|
||||
|
||||
const envTmpDir = process.env.DOCKER_ACTIONS_TOOLKIT_TMPDIR;
|
||||
const tmpDir = envTmpDir || fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
|
||||
|
||||
vi.mock('@actions/github');
|
||||
|
||||
process.env = Object.assign({}, process.env, {
|
||||
DOCKER_ACTIONS_TOOLKIT_TMPDIR: tmpDir,
|
||||
TEMP: tmpDir,
|
||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||
GITHUB_RUN_ATTEMPT: '2',
|
||||
GITHUB_RUN_ID: '2188748038',
|
||||
GITHUB_RUN_NUMBER: '15',
|
||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||
});
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
|
||||
import {BuildKit} from '../../src/buildkit/buildkit';
|
||||
import {Builder} from '../../src/buildx/builder';
|
||||
|
||||
import {BuilderInfo} from '../../src/types/buildx/builder';
|
||||
|
||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
return {
|
||||
name: 'builder2',
|
||||
driver: 'docker-container',
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, vi, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -25,14 +25,14 @@ import {Context} from '../../src/context';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildkit-config-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('resolve', () => {
|
||||
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
||||
expect(configValue).toEqual(exValue);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||
import {beforeEach, describe, expect, vi, test} from 'vitest';
|
||||
|
||||
import {Git} from '../../src/buildkit/git';
|
||||
|
||||
import {GitRef, GitURL} from '../../src/types/buildkit/git';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('parseURL', () => {
|
||||
@@ -195,7 +195,7 @@ describe('parseURL', () => {
|
||||
if (!expectedErr) {
|
||||
console.log(err);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(expectedErr).toBeTruthy();
|
||||
}
|
||||
});
|
||||
@@ -337,7 +337,7 @@ describe('parseRef', () => {
|
||||
if (expected) {
|
||||
console.log(err);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(expected).toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {afterEach, describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -29,15 +29,15 @@ import {BuildMetadata} from '../../src/types/buildx/build';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-bake-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-bake.json'), 'utf-8'));
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -25,15 +25,15 @@ import {Build} from '../../src/buildx/build';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-build-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-build.json'), 'utf-8'));
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ describe('resolveSecret', () => {
|
||||
expect(secret).toEqual(`id=${exKey},src=${tmpName}`);
|
||||
expect(fs.readFileSync(tmpName, 'utf-8')).toEqual(exValue);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
@@ -206,7 +206,7 @@ describe('resolveSecret', () => {
|
||||
const secret = Build.resolveSecretEnv(kvp);
|
||||
expect(secret).toEqual(`id=${exKey},env=${exValue}`);
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toEqual(error?.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -25,7 +25,7 @@ import {BuilderInfo} from '../../src/types/buildx/builder';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
vi.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => {
|
||||
return {
|
||||
name: 'builder2',
|
||||
driver: 'docker-container',
|
||||
@@ -46,7 +46,7 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
|
||||
|
||||
describe('exists', () => {
|
||||
it('valid', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const builder = new Builder();
|
||||
await builder.exists('foo');
|
||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'inspect', 'foo'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test, beforeEach, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -29,14 +29,14 @@ import {Cert, LocalState} from '../../src/types/buildx/buildx';
|
||||
|
||||
const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ afterEach(() => {
|
||||
describe('configDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: '/var/docker/buildx',
|
||||
@@ -69,7 +69,7 @@ describe('configDir', () => {
|
||||
describe('certsDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: '/var/docker/buildx'
|
||||
@@ -86,7 +86,7 @@ describe('certsDir', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const buildx = new Buildx({
|
||||
standalone: false
|
||||
});
|
||||
@@ -97,7 +97,7 @@ describe('isAvailable', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const buildx = new Buildx({
|
||||
standalone: true
|
||||
});
|
||||
@@ -111,7 +111,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const buildx = new Buildx({
|
||||
standalone: false
|
||||
});
|
||||
@@ -121,7 +121,7 @@ describe('printVersion', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const buildx = new Buildx({
|
||||
standalone: true
|
||||
});
|
||||
@@ -164,7 +164,7 @@ describe('versionSatisfies', () => {
|
||||
describe('resolveCertsDriverOpts', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
BUILDX_CONFIG: path.join(tmpDir, 'resolveCertsDriverOpts', 'buildx')
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/buildx/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -27,14 +27,14 @@ import {Exec} from '../../src/exec';
|
||||
import {Compose} from '../../src/compose/compose';
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'compose-compose-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ afterEach(() => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const compose = new Compose({
|
||||
standalone: false
|
||||
});
|
||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const compose = new Compose({
|
||||
standalone: true
|
||||
});
|
||||
@@ -69,7 +69,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('docker cli', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const compose = new Compose({
|
||||
standalone: false
|
||||
});
|
||||
@@ -79,7 +79,7 @@ describe('printVersion', () => {
|
||||
});
|
||||
});
|
||||
it('standalone', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const compose = new Compose({
|
||||
standalone: true
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/compose/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it, afterEach, beforeEach, test} from '@jest/globals';
|
||||
import {describe, expect, vi, it, afterEach, beforeEach, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -23,14 +23,14 @@ import * as rimraf from 'rimraf';
|
||||
import {Context} from '../src/context';
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-'));
|
||||
const tmpName = path.join(tmpDir, '.tmpname-jest');
|
||||
const tmpName = path.join(tmpDir, '.tmpname-vi');
|
||||
|
||||
jest.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpDir').mockImplementation((): string => {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
vi.spyOn(Context, 'tmpName').mockImplementation((): string => {
|
||||
return tmpName;
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ describe('gitRef', () => {
|
||||
describe('parseGitRef', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
DOCKER_GIT_CONTEXT_PR_HEAD_REF: ''
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
@@ -26,7 +26,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks Cosign is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const cosign = new Cosign();
|
||||
await cosign.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, [], {
|
||||
@@ -38,7 +38,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints Cosign version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const cosign = new Cosign();
|
||||
await cosign.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`cosign`, ['version', '--json'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/cosign/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
|
||||
import {Docker} from '../../src/docker/docker';
|
||||
|
||||
@@ -55,7 +55,7 @@ maybe('pull', () => {
|
||||
if (err === undefined) {
|
||||
throw new Error(`Expected no error, but got: ${e.message}`);
|
||||
}
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(e.message).toContain(err);
|
||||
}
|
||||
}, 600000);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -37,7 +37,7 @@ afterEach(function () {
|
||||
describe('configDir', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
DOCKER_CONFIG: '/var/docker/config'
|
||||
@@ -59,7 +59,7 @@ describe('configDir', () => {
|
||||
describe('configFile', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
if (!fs.existsSync(tmpDir)) {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
}
|
||||
@@ -97,7 +97,7 @@ describe('configFile', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('cli', async () => {
|
||||
const ioWhichSpy = jest.spyOn(io, 'which');
|
||||
const ioWhichSpy = vi.spyOn(io, 'which');
|
||||
await Docker.isAvailable();
|
||||
expect(ioWhichSpy).toHaveBeenCalledTimes(1);
|
||||
expect(ioWhichSpy).toHaveBeenCalledWith('docker', true);
|
||||
@@ -106,7 +106,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('exec', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.exec(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -133,7 +133,7 @@ describe('exec', () => {
|
||||
|
||||
describe('getExecOutput', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.getExecOutput(['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -160,7 +160,7 @@ describe('getExecOutput', () => {
|
||||
|
||||
describe('context', () => {
|
||||
it('call docker context show', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.context().catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -182,7 +182,7 @@ describe('context', () => {
|
||||
|
||||
describe('contextInspect', () => {
|
||||
it('call docker context inspect', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Docker, 'getExecOutput');
|
||||
await Docker.contextInspect('foo').catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -204,7 +204,7 @@ describe('contextInspect', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('call docker version', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.printVersion().catch(() => {
|
||||
// noop
|
||||
});
|
||||
@@ -220,7 +220,7 @@ describe('printVersion', () => {
|
||||
|
||||
describe('printInfo', () => {
|
||||
it('call docker info', async () => {
|
||||
const execSpy = jest.spyOn(Docker, 'exec');
|
||||
const execSpy = vi.spyOn(Docker, 'exec');
|
||||
await Docker.printInfo().catch(() => {
|
||||
// noop
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, test, expect} from '@jest/globals';
|
||||
import {beforeAll, describe, test, expect} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, test, beforeEach, afterEach, it} from '@jest/globals';
|
||||
import {describe, expect, vi, test, beforeEach, afterEach, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
@@ -103,7 +103,7 @@ describe('getRelease', () => {
|
||||
describe('limaImage', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
LIMA_IMAGES: `x86_64:https://cloud-images.ubuntu.com/releases/23.10/release-20231011/ubuntu-23.10-server-cloudimg-amd64.img@sha256:f6529be56da3429a56e4f5ef202bf4958201bc63f8541e478caa6e8eb712e635
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it} from '@jest/globals';
|
||||
import {describe, expect, vi, it} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -27,11 +27,11 @@ import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json';
|
||||
|
||||
describe('getRepository', () => {
|
||||
it('returns repo info', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepository').mockImplementation((): Promise<RepositoryResponse> => {
|
||||
return <Promise<RepositoryResponse>>(repoInfoFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
@@ -50,11 +50,11 @@ describe('getRepository', () => {
|
||||
|
||||
describe('getRepositoryTags', () => {
|
||||
it('return repo tags', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepositoryTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
return <Promise<RepositoryTagsResponse>>(repoTagsFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
@@ -74,11 +74,11 @@ describe('getRepositoryTags', () => {
|
||||
|
||||
describe('getRepositoryAllTags', () => {
|
||||
it('return repo all tags', async () => {
|
||||
jest.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
vi.spyOn(DockerHub.prototype, 'getRepositoryAllTags').mockImplementation((): Promise<RepositoryTagsResponse> => {
|
||||
return <Promise<RepositoryTagsResponse>>(repoAllTagsFixture as unknown);
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
jest.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
vi.spyOn(DockerHub as any, 'login').mockReturnValue('jwt_token');
|
||||
const dockerhub = await DockerHub.build({
|
||||
credentials: {
|
||||
username: 'foo',
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest} from '@jest/globals';
|
||||
import {describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {Exec} from '../src/exec';
|
||||
|
||||
describe('exec', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
await Exec.exec('docker', ['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
@@ -34,7 +34,7 @@ describe('exec', () => {
|
||||
|
||||
describe('getExecOutput', () => {
|
||||
it('returns docker version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
await Exec.getExecOutput('docker', ['version'], {
|
||||
ignoreReturnCode: true,
|
||||
silent: true
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import {beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {Git as GitMocked} from '../src/git';
|
||||
import {Exec} from '../src/exec';
|
||||
import {ExecOutput} from '@actions/exec';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('returns mocked ref and sha', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -54,7 +54,7 @@ describe('context', () => {
|
||||
|
||||
describe('isInsideWorkTree', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.isInsideWorkTree();
|
||||
} catch {
|
||||
@@ -72,8 +72,8 @@ describe('remoteSha', () => {
|
||||
expect(await GitMocked.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head')).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
||||
});
|
||||
it('returns sha using github api', async () => {
|
||||
jest.resetModules();
|
||||
jest.unmock('@actions/github');
|
||||
vi.resetModules();
|
||||
vi.unmock('@actions/github');
|
||||
const {Git} = await import('../src/git');
|
||||
expect(await Git.remoteSha('https://github.com/docker/buildx.git', 'refs/pull/648/head', process.env.GITHUB_TOKEN)).toEqual('f11797113e5a9b86bd976329c5dbb8a8bfdfadfa');
|
||||
});
|
||||
@@ -81,7 +81,7 @@ describe('remoteSha', () => {
|
||||
|
||||
describe('remoteURL', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.remoteURL();
|
||||
} catch {
|
||||
@@ -96,7 +96,7 @@ describe('remoteURL', () => {
|
||||
|
||||
describe('ref', () => {
|
||||
it('returns mocked ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -120,7 +120,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached tag ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -144,7 +144,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached tag ref (shallow clone)', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -168,7 +168,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached pull request merge ref (shallow clone)', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -192,7 +192,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('should throws an error when detached HEAD ref is not supported', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -214,7 +214,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached branch ref', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -238,7 +238,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('returns mocked detached branch ref checked out by SHA', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -262,7 +262,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from local branch when detached HEAD returns only "HEAD"', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -289,7 +289,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from local branch when detached HEAD returns only "grafted, HEAD"', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -316,7 +316,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from remote branch when no local branch contains HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -346,7 +346,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('infers ref from tag when no branch contains HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -379,7 +379,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('throws error when cannot infer ref from detached HEAD', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -410,7 +410,7 @@ describe('ref', () => {
|
||||
});
|
||||
|
||||
it('handles remote ref without branch pattern when inferring from remote', async () => {
|
||||
jest.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
vi.spyOn(Exec, 'getExecOutput').mockImplementation((cmd, args): Promise<ExecOutput> => {
|
||||
const fullCmd = `${cmd} ${args?.join(' ')}`;
|
||||
let result = '';
|
||||
switch (fullCmd) {
|
||||
@@ -442,7 +442,7 @@ describe('ref', () => {
|
||||
|
||||
describe('fullCommit', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.fullCommit();
|
||||
} catch {
|
||||
@@ -457,7 +457,7 @@ describe('fullCommit', () => {
|
||||
|
||||
describe('shortCommit', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.shortCommit();
|
||||
} catch {
|
||||
@@ -472,7 +472,7 @@ describe('shortCommit', () => {
|
||||
|
||||
describe('tag', () => {
|
||||
it('have been called', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
try {
|
||||
await GitMocked.tag();
|
||||
} catch {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, jest, it, beforeEach, afterEach, test} from '@jest/globals';
|
||||
import {describe, expect, vi, it, beforeEach, afterEach, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
@@ -28,7 +28,7 @@ const fixturesDir = path.join(__dirname, '..', '.fixtures');
|
||||
|
||||
describe('repoData', () => {
|
||||
it('returns GitHub repo data', async () => {
|
||||
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||
vi.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
||||
});
|
||||
const github = new GitHub();
|
||||
@@ -49,8 +49,8 @@ describe('repoData (api)', () => {
|
||||
};
|
||||
|
||||
try {
|
||||
jest.resetModules();
|
||||
jest.unmock('@actions/github');
|
||||
vi.resetModules();
|
||||
vi.unmock('@actions/github');
|
||||
const {GitHub} = await import('../../src/github/github');
|
||||
const github = new GitHub({token: process.env.GITHUB_TOKEN});
|
||||
const repo = await github.repoData();
|
||||
@@ -97,7 +97,7 @@ describe('releases', () => {
|
||||
describe('serverURL', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
GITHUB_SERVER_URL: 'https://foo.github.com'
|
||||
@@ -118,7 +118,7 @@ describe('serverURL', () => {
|
||||
describe('apiURL', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv,
|
||||
GITHUB_API_URL: 'https://bar.github.com'
|
||||
@@ -154,7 +154,7 @@ describe('workflowRunURL', () => {
|
||||
describe('actionsRuntimeToken', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv
|
||||
};
|
||||
@@ -184,7 +184,7 @@ describe('actionsRuntimeToken', () => {
|
||||
describe('printActionsRuntimeTokenACs', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
vi.resetModules();
|
||||
process.env = {
|
||||
...originalEnv
|
||||
};
|
||||
@@ -201,7 +201,7 @@ describe('printActionsRuntimeTokenACs', () => {
|
||||
await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('Cannot parse GitHub Actions Runtime Token: Invalid token specified: missing part #2'));
|
||||
});
|
||||
it('refs/heads/master', async () => {
|
||||
const infoSpy = jest.spyOn(core, 'info');
|
||||
const infoSpy = vi.spyOn(core, 'info');
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(fixturesDir, 'runtimeToken.txt')).toString().trim();
|
||||
await GitHub.printActionsRuntimeTokenACs();
|
||||
expect(infoSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {afterEach, describe, expect, test} from '@jest/globals';
|
||||
import {afterEach, describe, expect, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/regclient/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {Exec} from '../../src/exec';
|
||||
@@ -82,7 +82,7 @@ describe('image config', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks regctl is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const regctl = new Regctl();
|
||||
await regctl.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, [], {
|
||||
@@ -94,7 +94,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints regctl version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const regctl = new Regctl();
|
||||
await regctl.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`regctl`, ['version'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, expect, jest, it} from '@jest/globals';
|
||||
import {beforeAll, describe, expect, vi, it} from 'vitest';
|
||||
import * as path from 'path';
|
||||
|
||||
import {Buildx} from '../../src/buildx/buildx';
|
||||
@@ -31,7 +31,7 @@ const runTest = process.env.GITHUB_ACTIONS && process.env.GITHUB_ACTIONS === 'tr
|
||||
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||
|
||||
// needs current GitHub repo info
|
||||
jest.unmock('@actions/github');
|
||||
vi.unmock('@actions/github');
|
||||
|
||||
beforeAll(async () => {
|
||||
const cosignInstall = new CosignInstall();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {beforeAll, describe, expect, jest, it, test} from '@jest/globals';
|
||||
import {beforeAll, describe, expect, vi, it, test} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -34,7 +34,7 @@ const maybe = runTest ? describe : describe.skip;
|
||||
const maybeIdToken = runTest && process.env.ACTIONS_ID_TOKEN_REQUEST_URL ? describe : describe.skip;
|
||||
|
||||
// needs current GitHub repo info
|
||||
jest.unmock('@actions/github');
|
||||
vi.unmock('@actions/github');
|
||||
|
||||
beforeAll(async () => {
|
||||
const cosignInstall = new CosignInstall();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, test} from '@jest/globals';
|
||||
import {describe, expect, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {Install} from '../../src/undock/install';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test, afterEach} from '@jest/globals';
|
||||
import {describe, expect, it, test, afterEach} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it} from '@jest/globals';
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||
import {describe, expect, it, vi, test} from 'vitest';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {Exec} from '../../src/exec';
|
||||
@@ -43,7 +43,7 @@ describe('run', () => {
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('checks undock is available', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||
const execSpy = vi.spyOn(Exec, 'getExecOutput');
|
||||
const undock = new Undock();
|
||||
await undock.isAvailable();
|
||||
expect(execSpy).toHaveBeenCalledWith(`undock`, [], {
|
||||
@@ -55,7 +55,7 @@ describe('isAvailable', () => {
|
||||
|
||||
describe('printVersion', () => {
|
||||
it('prints undock version', async () => {
|
||||
const execSpy = jest.spyOn(Exec, 'exec');
|
||||
const execSpy = vi.spyOn(Exec, 'exec');
|
||||
const undock = new Undock();
|
||||
await undock.printVersion();
|
||||
expect(execSpy).toHaveBeenCalledWith(`undock`, ['--version'], {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals';
|
||||
import {describe, expect, it, test} from 'vitest';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -326,10 +326,10 @@ describe('parseBool', () => {
|
||||
].forEach(({input, expected, throwsError}) => {
|
||||
test(`parseBool("${input}")`, () => {
|
||||
if (throwsError) {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(() => Util.parseBool(input)).toThrow();
|
||||
} else {
|
||||
// eslint-disable-next-line jest/no-conditional-expect
|
||||
// eslint-disable-next-line vitest/no-conditional-expect
|
||||
expect(Util.parseBool(input)).toBe(expected);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user