@@ -365,6 +365,16 @@ void main() {
365
365
});
366
366
367
367
group ('doctor with fake validators' , () {
368
+ MockArtifacts mockArtifacts;
369
+ const String genSnapshotPath = '/path/to/gen_snapshot' ;
370
+ FileSystem memoryFileSystem;
371
+
372
+ setUp (() {
373
+ memoryFileSystem = MemoryFileSystem .test ();
374
+ mockArtifacts = MockArtifacts ();
375
+ when (mockArtifacts.getArtifactPath (Artifact .genSnapshot)).thenReturn (genSnapshotPath);
376
+ });
377
+
368
378
testUsingContext ('validate non-verbose output format for run without issues' , () async {
369
379
expect (await FakeQuietDoctor ().diagnose (verbose: false ), isTrue);
370
380
expect (testLogger.statusText, equals (
@@ -507,8 +517,9 @@ void main() {
507
517
}, overrides: noColorTerminalOverride);
508
518
509
519
testUsingContext ('gen_snapshot does not work' , () async {
520
+ memoryFileSystem.file (genSnapshotPath).createSync (recursive: true );
510
521
when (mockProcessManager.runSync (
511
- < String > [globals.artifacts. getArtifactPath ( Artifact .genSnapshot) ],
522
+ < String > [genSnapshotPath ],
512
523
workingDirectory: anyNamed ('workingDirectory' ),
513
524
environment: anyNamed ('environment' ),
514
525
)).thenReturn (ProcessResult (101 , 1 , '' , '' ));
@@ -524,30 +535,34 @@ void main() {
524
535
}
525
536
}
526
537
}, overrides: < Type , Generator > {
538
+ Artifacts : () => mockArtifacts,
539
+ FileSystem : () => memoryFileSystem,
527
540
OutputPreferences : () => OutputPreferences (wrapText: false ),
528
541
ProcessManager : () => mockProcessManager,
529
542
Platform : _kNoColorOutputPlatform,
530
543
});
531
544
532
545
testUsingContext ('gen_snapshot binary not available' , () async {
533
- expect (await FlutterValidatorDoctor ().diagnose (verbose: false ), isTrue);
534
- // gen_snapshot is downloaded on demand, and the doctor should not
535
- // fail if the gen_snapshot binary is not present.
536
- expect (testLogger.statusText, contains ('No issues found!' ));
546
+ expect (await FlutterValidatorDoctor ().diagnose (verbose: false ), isTrue);
547
+ // gen_snapshot is downloaded on demand, and the doctor should not
548
+ // fail if the gen_snapshot binary is not present.
549
+ expect (testLogger.statusText, contains ('No issues found!' ));
537
550
}, overrides: < Type , Generator > {
551
+ Artifacts : () => mockArtifacts,
538
552
FileSystem : () => MemoryFileSystem (),
539
553
ProcessManager : () => FakeProcessManager .any (),
540
554
});
541
555
542
556
testUsingContext ('version checking does not work' , () async {
557
+ memoryFileSystem.file (genSnapshotPath).createSync (recursive: true );
543
558
final VersionCheckError versionCheckError = VersionCheckError ('version error' );
544
559
545
560
when (mockFlutterVersion.channel).thenReturn ('unknown' );
546
561
when (mockFlutterVersion.frameworkVersion).thenReturn ('0.0.0' );
547
562
when (mockFlutterVersion.frameworkDate).thenThrow (versionCheckError);
548
563
549
564
when (mockProcessManager.runSync (
550
- < String > [globals.artifacts. getArtifactPath ( Artifact .genSnapshot) ],
565
+ < String > [genSnapshotPath ],
551
566
workingDirectory: anyNamed ('workingDirectory' ),
552
567
environment: anyNamed ('environment' ),
553
568
)).thenReturn (ProcessResult (101 , 255 , '' , '' ));
@@ -561,6 +576,8 @@ void main() {
561
576
'! Doctor found issues in 1 category.\n '
562
577
));
563
578
}, overrides: < Type , Generator > {
579
+ Artifacts : () => mockArtifacts,
580
+ FileSystem : () => memoryFileSystem,
564
581
OutputPreferences : () => OutputPreferences (wrapText: false ),
565
582
ProcessManager : () => mockProcessManager,
566
583
Platform : _kNoColorOutputPlatform,
@@ -736,6 +753,7 @@ void main() {
736
753
contains (isA <WebWorkflow >()));
737
754
}, overrides: < Type , Generator > {
738
755
FeatureFlags : () => TestFeatureFlags (isWebEnabled: true ),
756
+ FileSystem : () => MemoryFileSystem .test (),
739
757
ProcessManager : () => MockProcessManager (),
740
758
});
741
759
@@ -1122,3 +1140,4 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
1122
1140
}
1123
1141
1124
1142
class MockProcessManager extends Mock implements ProcessManager {}
1143
+ class MockArtifacts extends Mock implements Artifacts {}
0 commit comments