mirror of
https://github.com/subosito/flutter-action.git
synced 2026-11-05 10:15:50 +00:00
added test for fetching latest release
This commit is contained in:
4 files changed
+4574
No files matched your search
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
@@ -1,15 +1,28 @@
|
|||||||
import io = require('@actions/io');
|
import io = require('@actions/io');
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import path = require('path');
|
import path = require('path');
|
||||||
|
import nock = require('nock');
|
||||||
|
|
||||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||||
|
const dataDir = path.join(__dirname, 'data');
|
||||||
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
process.env['RUNNER_TEMP'] = tempDir;
|
||||||
|
|
||||||
import * as installer from '../src/installer';
|
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', () => {
|
describe('installer tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await io.rmRF(toolDir);
|
await io.rmRF(toolDir);
|
||||||
@@ -38,6 +51,25 @@ describe('installer tests', () => {
|
|||||||
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
expect(fs.existsSync(path.join(sdkDir, 'bin'))).toBe(true);
|
||||||
}, 100000);
|
}, 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 () => {
|
it('Downloads flutter from beta channel', async () => {
|
||||||
await installer.getFlutter('1.8.3', 'beta');
|
await installer.getFlutter('1.8.3', 'beta');
|
||||||
const sdkDir = path.join(toolDir, 'flutter', '1.8.3-beta', 'x64');
|
const sdkDir = path.join(toolDir, 'flutter', '1.8.3-beta', 'x64');
|
||||||
|
|||||||
Reference in new issue
Block a user