1
0
Fork 0
mirror of https://github.com/subosito/flutter-action.git synced 2024-08-16 10:19:50 +02:00

added test for fetching latest release

This commit is contained in:
Alif Rachmawadi 2019-08-16 18:31:13 +07:00
parent 62ca43375c
commit 858e055b72
No known key found for this signature in database
GPG key ID: 79DA63C0F3A55BB1
4 changed files with 4574 additions and 0 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,28 @@
import io = require('@actions/io');
import fs = require('fs');
import path = require('path');
import nock = require('nock');
const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
const dataDir = path.join(__dirname, 'data');
process.env['RUNNER_TOOL_CACHE'] = toolDir;
process.env['RUNNER_TEMP'] = tempDir;
import * as installer from '../src/installer';
function osName(): string {
switch (process.platform) {
case 'win32':
return 'windows';
case 'darwin':
return 'macos';
default:
return process.platform;
}
}
describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
@ -38,6 +51,25 @@ describe('installer tests', () => {
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads latest flutter release from stable channel', async () => {
const platform = osName();
nock('https://storage.googleapis.com')
.get(`/flutter_infra/releases/releases_${platform}.json`)
.replyWithFile(200, path.join(dataDir, `releases_${platform}.json`));
await installer.getFlutter('', 'stable');
const sdkDir = path.join(
toolDir,
'flutter',
'1.7.8-hotfix.4-stable',
'x64'
);
expect(fs.existsSync(`${sdkDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
}, 100000);
it('Downloads flutter from beta channel', async () => {
await installer.getFlutter('1.8.3', 'beta');
const sdkDir = path.join(toolDir, 'flutter', '1.8.3-beta', 'x64');