Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with multiple versions #13

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,33 @@ jobs:
- name: Verify dotnet
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^3.1.201$" -CheckNugetConfig

test-sequential-version-installation:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
lower-version: ['2.2.402', '3.0.103', '3.1.426', '6.0.408', '7.0.100']
higher-version: ['6.0.408', '7.0.203']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clear toolcache
shell: pwsh
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
# Install one version, use it for something, then switch to next version
- name: Setup dotnet (lower version)
uses: ./
with:
dotnet-version: ${{ matrix.lower-version }}
- name: Verify dotnet (lower version)
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.lower-version }}$"
- name: Setup dotnet (higher version)
uses: ./
with:
dotnet-version: ${{ matrix.higher-version }}
- name: Verify dotnet (higher version)
shell: pwsh
run: __tests__/verify-dotnet.ps1 -Patterns "^${{ matrix.lower-version }}$", "^${{ matrix.higher-version }}$"
51 changes: 41 additions & 10 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet();

const scriptArguments = (
getExecOutputSpy.mock.calls[0][1] as string[]
getExecOutputSpy.mock.calls[1][1] as string[]
).join(' ');
const expectedArgument = IS_WINDOWS
? `-Version ${inputVersion}`
Expand Down Expand Up @@ -130,6 +130,37 @@ describe('installer tests', () => {
);
});

it('should call install script 2 times: for the runtime and for the sdk', async () => {
const inputVersion = '6.0.300';
const inputQuality = '' as QualityOptions;

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
});
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
inputQuality
);

await dotnetInstaller.installDotnet();

expect(getExecOutputSpy.mock.calls.length).toEqual(2);

expect(getExecOutputSpy.mock.calls[0][1]?.join(' ')).toContain(
IS_WINDOWS ? '-Channel LTS' : '--channel LTS'
);

expect(getExecOutputSpy.mock.calls[0][1]?.join(' ')).toContain(
IS_WINDOWS ? '-Runtime dotnet' : '--runtime dotnet'
);

expect(getExecOutputSpy.mock.calls[1][1]?.join(' ')).toContain(
IS_WINDOWS ? `-Version ${inputVersion}` : `--version ${inputVersion}`
);
});

each(['6', '6.0', '6.0.x', '6.0.*', '6.0.X']).test(
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
async inputVersion => {
Expand All @@ -152,7 +183,7 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet();

const scriptArguments = (
getExecOutputSpy.mock.calls[0][1] as string[]
getExecOutputSpy.mock.calls[1][1] as string[]
).join(' ');
const expectedArgument = IS_WINDOWS
? `-Quality ${inputQuality}`
Expand Down Expand Up @@ -184,7 +215,7 @@ describe('installer tests', () => {
await dotnetInstaller.installDotnet();

const scriptArguments = (
getExecOutputSpy.mock.calls[0][1] as string[]
getExecOutputSpy.mock.calls[1][1] as string[]
).join(' ');
const expectedArgument = IS_WINDOWS
? `-Channel 6.0`
Expand Down Expand Up @@ -267,7 +298,7 @@ describe('installer tests', () => {
});

describe('DotnetVersionResolver tests', () => {
describe('createDotNetVersion() tests', () => {
describe('createDotnetVersion() tests', () => {
each([
'3.1',
'3.x',
Expand All @@ -283,7 +314,7 @@ describe('installer tests', () => {
version
);
const versionObject =
await dotnetVersionResolver.createDotNetVersion();
await dotnetVersionResolver.createDotnetVersion();

expect(!!versionObject.value).toBe(true);
}
Expand Down Expand Up @@ -322,7 +353,7 @@ describe('installer tests', () => {
);

await expect(
async () => await dotnetVersionResolver.createDotNetVersion()
async () => await dotnetVersionResolver.createDotnetVersion()
).rejects.toThrow();
}
);
Expand All @@ -334,7 +365,7 @@ describe('installer tests', () => {
version
);
const versionObject =
await dotnetVersionResolver.createDotNetVersion();
await dotnetVersionResolver.createDotnetVersion();

expect(versionObject.type.toLowerCase().includes('channel')).toBe(
true
Expand All @@ -349,7 +380,7 @@ describe('installer tests', () => {
version
);
const versionObject =
await dotnetVersionResolver.createDotNetVersion();
await dotnetVersionResolver.createDotnetVersion();

expect(versionObject.type.toLowerCase().includes('channel')).toBe(
true
Expand All @@ -365,7 +396,7 @@ describe('installer tests', () => {
version
);
const versionObject =
await dotnetVersionResolver.createDotNetVersion();
await dotnetVersionResolver.createDotnetVersion();

expect(versionObject.type.toLowerCase().includes('version')).toBe(
true
Expand All @@ -381,7 +412,7 @@ describe('installer tests', () => {
version
);
const versionObject =
await dotnetVersionResolver.createDotNetVersion();
await dotnetVersionResolver.createDotnetVersion();
const windowsRegEx = new RegExp(/^-(Version|Channel)/);
const nonWindowsRegEx = new RegExp(/^--(version|channel)/);

Expand Down
Loading