Run the flutter_tools create test in online mode before testing offline mode (#89779)

Offline pub assumes that the pub cache contains all needed packages.  Running
"flutter create" in online mode first will ensure that the pub cache is populated.

Fixes https://github.com/flutter/flutter/issues/89759
This commit is contained in:
Jason Simmons 2021-09-09 13:31:37 -07:00 committed by GitHub
parent 000f4444b8
commit a14be9d290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1702,13 +1702,20 @@ void main() {
});
testUsingContext(
'invokes pub offline when requested',
'invokes pub in online and offline modes',
() async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
// Run pub online first in order to populate the pub cache.
await runner.run(<String>['create', '--pub', projectDir.path]);
expect(loggingProcessManager.commands.first, contains(matches(r'dart-sdk[\\/]bin[\\/]dart')));
expect(loggingProcessManager.commands.first, isNot(contains('--offline')));
// Run pub offline.
loggingProcessManager.clear();
await runner.run(<String>['create', '--pub', '--offline', projectDir.path]);
expect(loggingProcessManager.commands.first, contains(matches(r'dart-sdk[\\/]bin[\\/]dart')));
expect(loggingProcessManager.commands.first, contains('--offline'));
@ -2820,4 +2827,8 @@ class LoggingProcessManager extends LocalProcessManager {
mode: mode,
);
}
void clear() {
commands.clear();
}
}