Format: Increase amount of retries for Dotnet installation scripts tests

This commit is contained in:
Nikolai Laevskii 2023-05-18 12:02:09 +02:00
parent ed16ccab85
commit 6fb866f807

View File

@ -2,43 +2,59 @@ import path from 'path';
import fs from 'fs'; import fs from 'fs';
import * as hc from '@actions/http-client'; import * as hc from '@actions/http-client';
const HTTP_CLIENT_OPTIONS = { allowRetries: true, maxRetries: 10 } as const; const HTTP_CLIENT_OPTIONS = {allowRetries: true, maxRetries: 10} as const;
const TEST_TIMEOUT = 30000; const TEST_TIMEOUT = 30000;
describe('Dotnet installation scripts tests', () => { describe('Dotnet installation scripts tests', () => {
it('Uses an up to date bash download script', async () => { it(
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], HTTP_CLIENT_OPTIONS); 'Uses an up to date bash download script',
const response: hc.HttpClientResponse = await httpCallbackClient.get( async () => {
'https://dot.net/v1/dotnet-install.sh' const httpCallbackClient = new hc.HttpClient(
); 'setup-dotnet-test',
expect(response.message.statusCode).toBe(200); [],
const upToDateContents: string = await response.readBody(); HTTP_CLIENT_OPTIONS
const currentContents: string = fs );
.readFileSync( const response: hc.HttpClientResponse = await httpCallbackClient.get(
path.join(__dirname, '..', 'externals', 'install-dotnet.sh') 'https://dot.net/v1/dotnet-install.sh'
) );
.toString(); expect(response.message.statusCode).toBe(200);
expect(normalizeFileContents(currentContents)).toBe( const upToDateContents: string = await response.readBody();
normalizeFileContents(upToDateContents) const currentContents: string = fs
); .readFileSync(
}, TEST_TIMEOUT); path.join(__dirname, '..', 'externals', 'install-dotnet.sh')
)
.toString();
expect(normalizeFileContents(currentContents)).toBe(
normalizeFileContents(upToDateContents)
);
},
TEST_TIMEOUT
);
it('Uses an up to date powershell download script', async () => { it(
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], HTTP_CLIENT_OPTIONS); 'Uses an up to date powershell download script',
const response: hc.HttpClientResponse = await httpCallbackClient.get( async () => {
'https://dot.net/v1/dotnet-install.ps1' const httpCallbackClient = new hc.HttpClient(
); 'setup-dotnet-test',
expect(response.message.statusCode).toBe(200); [],
const upToDateContents: string = await response.readBody(); HTTP_CLIENT_OPTIONS
const currentContents: string = fs );
.readFileSync( const response: hc.HttpClientResponse = await httpCallbackClient.get(
path.join(__dirname, '..', 'externals', 'install-dotnet.ps1') 'https://dot.net/v1/dotnet-install.ps1'
) );
.toString(); expect(response.message.statusCode).toBe(200);
expect(normalizeFileContents(currentContents)).toBe( const upToDateContents: string = await response.readBody();
normalizeFileContents(upToDateContents) const currentContents: string = fs
); .readFileSync(
}, TEST_TIMEOUT); path.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
)
.toString();
expect(normalizeFileContents(currentContents)).toBe(
normalizeFileContents(upToDateContents)
);
},
TEST_TIMEOUT
);
}); });
function normalizeFileContents(contents: string): string { function normalizeFileContents(contents: string): string {