mirror of
https://github.com/actions/setup-go.git
synced 2025-09-07 18:53:38 -06:00
Add unit tests
This commit is contained in:
parent
6f72b31c94
commit
deaf43692d
7 changed files with 114 additions and 78 deletions
|
@ -2,8 +2,11 @@ import * as core from '@actions/core';
|
|||
import * as cache from '@actions/cache';
|
||||
import fs from 'fs';
|
||||
import {State} from './constants';
|
||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||
import {getCacheInput} from './utils';
|
||||
import {
|
||||
getCacheDirectoryPath,
|
||||
getPackageManagerInfo,
|
||||
getCacheInput
|
||||
} from './cache-utils';
|
||||
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as cache from '@actions/cache';
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import {supportedPackageManagers, PackageManagerInfo} from './package-managers';
|
||||
import {isSelfHosted} from './utils';
|
||||
|
||||
export const getCommandOutput = async (toolCommand: string) => {
|
||||
let {stdout, stderr, exitCode} = await exec.getExecOutput(
|
||||
|
@ -83,3 +84,9 @@ export function isCacheFeatureAvailable(): boolean {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
export const getCacheInput = (): boolean => {
|
||||
// for self-hosted environment turn off cache by default
|
||||
if (isSelfHosted() && core.getInput('cache') === '') return false;
|
||||
|
||||
return core.getBooleanInput('cache');
|
||||
};
|
||||
|
|
|
@ -4,11 +4,10 @@ import * as installer from './installer';
|
|||
import * as semver from 'semver';
|
||||
import path from 'path';
|
||||
import {restoreCache} from './cache-restore';
|
||||
import {isCacheFeatureAvailable} from './cache-utils';
|
||||
import {isCacheFeatureAvailable, getCacheInput} from './cache-utils';
|
||||
import cp from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {getCacheInput} from './utils';
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
|
|
|
@ -7,11 +7,4 @@ export enum StableReleaseAlias {
|
|||
|
||||
export const isSelfHosted = (): boolean =>
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||
process.env['AGENT_ISSELFHOSTED'] === '1';
|
||||
|
||||
export const getCacheInput = (): boolean => {
|
||||
// for self-hosted environment turn off cache by default
|
||||
if (isSelfHosted() && core.getInput('cache') === '') return false;
|
||||
|
||||
return core.getBooleanInput('cache');
|
||||
};
|
||||
process.env['AGENT_ISSELFHOSTED'] !== '0';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue