From 389e13f8b9f5a1c67b9d55c5d0096fa401f5410d Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Wed, 6 Dec 2017 13:27:29 -0800 Subject: [PATCH] Fixing the pub get test so that it doesn't care what the flutter root looks like. (#13385) --- .../flutter_tools/test/dart/pub_get_test.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/test/dart/pub_get_test.dart b/packages/flutter_tools/test/dart/pub_get_test.dart index 355983cef1..578adf8b53 100644 --- a/packages/flutter_tools/test/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/dart/pub_get_test.dart @@ -6,6 +6,7 @@ import 'dart:async'; import 'package:file/file.dart'; import 'package:file/memory.dart'; +import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/platform.dart'; @@ -16,9 +17,14 @@ import 'package:process/process.dart'; import 'package:quiver/testing/async.dart'; import 'package:test/test.dart'; +import '../src/common.dart'; import '../src/context.dart'; void main() { + setUpAll(() { + Cache.flutterRoot = getFlutterRoot(); + }); + testUsingContext('pub get 69', () async { String error; @@ -91,6 +97,7 @@ void main() { String error; final MockProcessManager processMock = context.getVariable(ProcessManager); + final MockFileSystem fsMock = context.getVariable(FileSystem); new FakeAsync().run((FakeAsync time) { MockDirectory.findCache = true; @@ -102,7 +109,7 @@ void main() { error = 'test failed unexpectedly: $thrownError'; }); time.elapse(const Duration(milliseconds: 500)); - expect(processMock.lastPubCache, endsWith('flutter/.pub-cache')); + expect(processMock.lastPubCache, equals(fsMock.path.join(Cache.flutterRoot, '.pub-cache'))); expect(error, isNull); }); }, overrides: { @@ -119,7 +126,7 @@ void main() { final MockProcessManager processMock = context.getVariable(ProcessManager); new FakeAsync().run((FakeAsync time) { - MockDirectory.findCache = false; + MockDirectory.findCache = true; expect(processMock.lastPubEnvironmment, isNull); expect(processMock.lastPubCache, isNull); pubGet(context: PubContext.flutterTests, checkLastModified: false).then((Null value) { @@ -128,14 +135,14 @@ void main() { error = 'test failed unexpectedly: $thrownError'; }); time.elapse(const Duration(milliseconds: 500)); - expect(processMock.lastPubCache, equals('path/to/pub-cache')); + expect(processMock.lastPubCache, equals('custom/pub-cache/path')); expect(error, isNull); }); }, overrides: { ProcessManager: () => new MockProcessManager(69), FileSystem: () => new MockFileSystem(), Platform: () => new FakePlatform( - environment: {'PUB_CACHE': 'path/to/pub-cache'}, + environment: {'PUB_CACHE': 'custom/pub-cache/path'}, ), }); }