|
|
|
@ -4,7 +4,7 @@ import semver from 'semver';
|
|
|
|
|
import * as auth from '../src/authutil';
|
|
|
|
|
|
|
|
|
|
import * as setup from '../src/setup-dotnet';
|
|
|
|
|
import {DotnetCoreInstaller} from '../src/installer';
|
|
|
|
|
import {DotnetCoreInstaller, DotnetInstallDir} from '../src/installer';
|
|
|
|
|
|
|
|
|
|
describe('setup-dotnet tests', () => {
|
|
|
|
|
const inputs = {} as any;
|
|
|
|
@ -25,17 +25,19 @@ describe('setup-dotnet tests', () => {
|
|
|
|
|
DotnetCoreInstaller.prototype,
|
|
|
|
|
'installDotnet'
|
|
|
|
|
);
|
|
|
|
|
const addToPathSpy = jest.spyOn(DotnetCoreInstaller, 'addToPath');
|
|
|
|
|
|
|
|
|
|
const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication');
|
|
|
|
|
const addToPathOriginal = DotnetInstallDir.addToPath;
|
|
|
|
|
|
|
|
|
|
describe('run() tests', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
DotnetInstallDir.addToPath = jest.fn();
|
|
|
|
|
getMultilineInputSpy.mockImplementation(input => inputs[input as string]);
|
|
|
|
|
getInputSpy.mockImplementation(input => inputs[input as string]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
DotnetInstallDir.addToPath = addToPathOriginal;
|
|
|
|
|
jest.clearAllMocks();
|
|
|
|
|
jest.resetAllMocks();
|
|
|
|
|
});
|
|
|
|
@ -96,10 +98,9 @@ describe('setup-dotnet tests', () => {
|
|
|
|
|
inputs['dotnet-quality'] = '';
|
|
|
|
|
|
|
|
|
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
|
|
|
|
addToPathSpy.mockImplementation(() => {});
|
|
|
|
|
|
|
|
|
|
await setup.run();
|
|
|
|
|
expect(addToPathSpy).toHaveBeenCalledTimes(1);
|
|
|
|
|
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should call auth.configAuthentication() if source-url input is provided', async () => {
|
|
|
|
@ -140,10 +141,9 @@ describe('setup-dotnet tests', () => {
|
|
|
|
|
installDotnetSpy.mockImplementation(() =>
|
|
|
|
|
Promise.resolve(`${inputs['dotnet-version']}`)
|
|
|
|
|
);
|
|
|
|
|
addToPathSpy.mockImplementation(() => {});
|
|
|
|
|
|
|
|
|
|
await setup.run();
|
|
|
|
|
expect(setOutputSpy).toHaveBeenCalledTimes(1);
|
|
|
|
|
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => {
|
|
|
|
@ -151,7 +151,6 @@ describe('setup-dotnet tests', () => {
|
|
|
|
|
const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`;
|
|
|
|
|
|
|
|
|
|
installDotnetSpy.mockImplementation(() => Promise.resolve(null));
|
|
|
|
|
addToPathSpy.mockImplementation(() => {});
|
|
|
|
|
|
|
|
|
|
await setup.run();
|
|
|
|
|
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
|
|
|
@ -162,8 +161,6 @@ describe('setup-dotnet tests', () => {
|
|
|
|
|
inputs['dotnet-version'] = [];
|
|
|
|
|
const warningMessage = `The 'dotnet-version' output will not be set.`;
|
|
|
|
|
|
|
|
|
|
addToPathSpy.mockImplementation(() => {});
|
|
|
|
|
|
|
|
|
|
await setup.run();
|
|
|
|
|
|
|
|
|
|
expect(infoSpy).toHaveBeenCalledWith(warningMessage);
|
|
|
|
|