Skip to content

Commit

Permalink
WIP release 3.0.0:
Browse files Browse the repository at this point in the history
- Test-coverage
- Fix failing ci test
  • Loading branch information
buijs-dev committed May 4, 2024
1 parent a52a611 commit 2b47ecc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/src/cli/task_get_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GetFlutterSDK extends Task {
if (!skipDownload(options[TaskOption.dryRun])) {
final zip = target.resolveFile("flutter.zip")
..maybeDelete
..createSync();
..createSync(recursive: true);
await downloadOrThrow(endpoint, zip, target);
}
}
Expand All @@ -70,7 +70,7 @@ class GetFlutterSDK extends Task {
///
/// Defaults to false and will download flutter sdk.
bool skipDownload(dynamic dryRun) =>
Platform.environment["GET_FLUTTER_SDK_SKIP"] != null || dryRun == true;
platform.environment["GET_FLUTTER_SDK_SKIP"] != null || dryRun == true;

/// Downloading the sdk is not required when the sdk
/// already exists and [TaskOption.overwrite] is false.
Expand Down
6 changes: 5 additions & 1 deletion lib/src/common/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ PlatformWrapper platform = PlatformWrapper();

/// Wrapper for [Platform].
class PlatformWrapper {

/// Stub for environment properties.
Map<String, String> environmentMap = Platform.environment;

/// Get the current Operating System through [Platform.operatingSystem].
String get operatingSystem => Platform.operatingSystem;

/// Get the environment variables through [Platform.environment].
Map<String, String> get environment => Platform.environment;
Map<String, String> get environment => environmentMap;

/// Check if current platform is windows.
bool get isWindows => Platform.isWindows;
Expand Down
21 changes: 21 additions & 0 deletions test/src/cli/task_get_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ void main() {
}));
expect(result.isOk, true, reason: result.message ?? "");
});

test("Verify skipDownload", () async {
platform = PlatformWrapper()
..environmentMap = {"GET_FLUTTER_SDK_SKIP": "SKIPPIE"};
final task = GetFlutterSDK();
expect(task.skipDownload(true), true);
expect(task.skipDownload(false), true);
platform = PlatformWrapper();
expect(task.skipDownload(true), true);
expect(task.skipDownload(false), false);
});

test("Verify requiresDownload", () async {
final task = GetFlutterSDK();
final fakeDirectory = Directory("fake");
final realDirectory = Directory.current;
expect(task.requiresDownload(fakeDirectory, false), true);
expect(task.requiresDownload(fakeDirectory, true), true);
expect(task.requiresDownload(realDirectory, false), false);
expect(task.requiresDownload(realDirectory, true), true);
});
}

Context context(Map<TaskOption, String> options) => Context(
Expand Down

0 comments on commit 2b47ecc

Please sign in to comment.