Skip to content

Commit

Permalink
add test of flutter update-packages --transitive-closure --consumer-o…
Browse files Browse the repository at this point in the history
…nly (#116747)
  • Loading branch information
christopherfujino authored Dec 9, 2022
1 parent 117a83a commit afdc484
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/update_packages.dart';
import 'package:flutter_tools/src/dart/pub.dart';
Expand Down Expand Up @@ -88,9 +89,11 @@ void main() {
late Directory flutter;
late FakePub pub;
late FakeProcessManager processManager;
late BufferLogger logger;

setUpAll(() {
Cache.disableLocking();
logger = BufferLogger.test();
});

setUp(() {
Expand Down Expand Up @@ -174,6 +177,35 @@ void main() {
),
});

testUsingContext('--transitive-closure --consumer-only', () async {
final UpdatePackagesCommand command = UpdatePackagesCommand();
await createTestCommandRunner(command).run(<String>[
'update-packages',
'--transitive-closure',
'--consumer-only',
]);
expect(pub.pubGetDirectories, equals(<String>[
'/.tmp_rand0/flutter_update_packages.rand0/synthetic_package',
]));
expect(pub.pubBatchDirectories, equals(<String>[
'/.tmp_rand0/flutter_update_packages.rand0/synthetic_package',
]));
// Expecting a line like:
// 'flutter -> {collection, meta, typed_data, vector_math}'
expect(
logger.statusText,
contains(RegExp(r'flutter -> {([a-z_]+, )*([a-z_]+)+}')),
);
}, overrides: <Type, Generator>{
Pub: () => pub,
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
Cache: () => Cache.test(
processManager: processManager,
),
Logger: () => logger,
});

testUsingContext('force updates packages --synthetic-package-path', () async {
final UpdatePackagesCommand command = UpdatePackagesCommand();
const String dir = '/path/to/synthetic/package';
Expand Down

0 comments on commit afdc484

Please sign in to comment.