@@ -393,6 +393,44 @@ void main() {
393393 expect (operatingSystemUtils.chmods, < List <String >> [< String > ['/.tmp_rand0/flutter_cache_test_artifact.rand0/bin_dir' , 'a+r,a+x' ]]);
394394 });
395395
396+ testWithoutContext ('EngineCachedArtifact downloads package zip from expected URL' , () async {
397+ final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils ();
398+ final FileSystem fileSystem = MemoryFileSystem .test ();
399+ final Directory artifactDir = fileSystem.systemTempDirectory.createTempSync ('flutter_cache_test_artifact.' );
400+ final Directory downloadDir = fileSystem.systemTempDirectory.createTempSync ('flutter_cache_test_download.' );
401+ final FakeSecondaryCache cache = FakeSecondaryCache ()
402+ ..artifactDirectory = artifactDir
403+ ..downloadDir = downloadDir;
404+ artifactDir.childDirectory ('pkg' ).createSync ();
405+
406+ final FakeCachedArtifact artifact = FakeCachedArtifact (
407+ cache: cache,
408+ binaryDirs: < List <String >> [],
409+ packageDirs: < String > [
410+ 'package_dir' ,
411+ ],
412+ requiredArtifacts: DevelopmentArtifact .universal,
413+ );
414+
415+ Uri ? packageUrl;
416+ final ArtifactUpdater artifactUpdater = FakeArtifactUpdater ()
417+ ..onDownloadZipArchive = (String message, Uri url, Directory location) {
418+ location.childDirectory ('package_dir' ).createSync ();
419+ packageUrl = url;
420+ };
421+
422+ await artifact.updateInner (artifactUpdater, fileSystem, operatingSystemUtils);
423+ expect (packageUrl, isNotNull);
424+ expect (packageUrl.toString (), 'https://storage.googleapis.com/flutter_infra_release/flutter/null/package_dir.zip' );
425+
426+ final Directory dir = fileSystem.systemTempDirectory
427+ .listSync (recursive: true )
428+ .whereType <Directory >()
429+ .singleWhereOrNull ((Directory directory) => directory.basename == 'pkg' )! ;
430+ expect (dir.path, artifactDir.childDirectory ('pkg' ).path);
431+ expect (dir.childDirectory ('package_dir' ).existsSync (), isTrue);
432+ });
433+
396434 testWithoutContext ('Try to remove without a parent' , () async {
397435 final FileSystem fileSystem = MemoryFileSystem .test ();
398436 final Directory parent = fileSystem.directory ('dir' );
0 commit comments