2023-05-15 19:09:29 +07:00
|
|
|
import path from 'path';
|
|
|
|
import fs from 'fs';
|
|
|
|
import * as hc from '@actions/http-client';
|
|
|
|
|
2023-05-19 13:50:54 +07:00
|
|
|
const HTTP_CLIENT_OPTIONS = {allowRetries: true, maxRetries: 10} as const;
|
|
|
|
const TEST_TIMEOUT = 30000;
|
|
|
|
|
2023-05-15 19:09:29 +07:00
|
|
|
describe('Dotnet installation scripts tests', () => {
|
2023-05-19 13:50:54 +07:00
|
|
|
it(
|
|
|
|
'Uses an up to date bash download script',
|
|
|
|
async () => {
|
|
|
|
const httpCallbackClient = new hc.HttpClient(
|
|
|
|
'setup-dotnet-test',
|
|
|
|
[],
|
|
|
|
HTTP_CLIENT_OPTIONS
|
|
|
|
);
|
|
|
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
|
|
|
'https://dot.net/v1/dotnet-install.sh'
|
|
|
|
);
|
|
|
|
expect(response.message.statusCode).toBe(200);
|
|
|
|
const upToDateContents: string = await response.readBody();
|
|
|
|
const currentContents: string = fs
|
|
|
|
.readFileSync(
|
|
|
|
path.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
|
|
|
)
|
|
|
|
.toString();
|
|
|
|
expect(normalizeFileContents(currentContents)).toBe(
|
|
|
|
normalizeFileContents(upToDateContents)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
TEST_TIMEOUT
|
|
|
|
);
|
2023-05-15 19:09:29 +07:00
|
|
|
|
2023-05-19 13:50:54 +07:00
|
|
|
it(
|
|
|
|
'Uses an up to date powershell download script',
|
|
|
|
async () => {
|
|
|
|
const httpCallbackClient = new hc.HttpClient(
|
|
|
|
'setup-dotnet-test',
|
|
|
|
[],
|
|
|
|
HTTP_CLIENT_OPTIONS
|
|
|
|
);
|
|
|
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
|
|
|
'https://dot.net/v1/dotnet-install.ps1'
|
|
|
|
);
|
|
|
|
expect(response.message.statusCode).toBe(200);
|
|
|
|
const upToDateContents: string = await response.readBody();
|
|
|
|
const currentContents: string = fs
|
|
|
|
.readFileSync(
|
|
|
|
path.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
|
|
|
)
|
|
|
|
.toString();
|
|
|
|
expect(normalizeFileContents(currentContents)).toBe(
|
|
|
|
normalizeFileContents(upToDateContents)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
TEST_TIMEOUT
|
|
|
|
);
|
2023-05-15 19:09:29 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
function normalizeFileContents(contents: string): string {
|
|
|
|
return contents
|
|
|
|
.trim()
|
|
|
|
.replace(new RegExp('\r\n', 'g'), '\n')
|
|
|
|
.replace(new RegExp('\r', 'g'), '\n');
|
|
|
|
}
|