Lazy cache 5: The Empire Strikes Back (#29986)
This commit is contained in:
@@ -103,9 +103,9 @@ void main() {
|
||||
when(artifact1.isUpToDate()).thenReturn(true);
|
||||
when(artifact2.isUpToDate()).thenReturn(false);
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
await cache.updateAll();
|
||||
verifyNever(artifact1.update());
|
||||
verify(artifact2.update());
|
||||
await cache.updateAll(<DevelopmentArtifact>{});
|
||||
verifyNever(artifact1.update(<DevelopmentArtifact>{}));
|
||||
verify(artifact2.update(<DevelopmentArtifact>{}));
|
||||
});
|
||||
testUsingContext('failed storage.googleapis.com download shows China warning', () async {
|
||||
final CachedArtifact artifact1 = MockCachedArtifact();
|
||||
@@ -114,18 +114,18 @@ void main() {
|
||||
when(artifact2.isUpToDate()).thenReturn(false);
|
||||
final MockInternetAddress address = MockInternetAddress();
|
||||
when(address.host).thenReturn('storage.googleapis.com');
|
||||
when(artifact1.update()).thenThrow(SocketException(
|
||||
when(artifact1.update(<DevelopmentArtifact>{})).thenThrow(SocketException(
|
||||
'Connection reset by peer',
|
||||
address: address,
|
||||
));
|
||||
final Cache cache = Cache(artifacts: <CachedArtifact>[artifact1, artifact2]);
|
||||
try {
|
||||
await cache.updateAll();
|
||||
await cache.updateAll(<DevelopmentArtifact>{});
|
||||
fail('Mock thrown exception expected');
|
||||
} catch (e) {
|
||||
verify(artifact1.update());
|
||||
verify(artifact1.update(<DevelopmentArtifact>{}));
|
||||
// Don't continue when retrieval fails.
|
||||
verifyNever(artifact2.update());
|
||||
verifyNever(artifact2.update(<DevelopmentArtifact>{}));
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
contains('https://flutter.io/community/china'),
|
||||
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
testUsingContext('honors shouldUpdateCache true', () async {
|
||||
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true);
|
||||
await flutterCommand.run();
|
||||
verify(cache.updateAll()).called(1);
|
||||
verify(cache.updateAll(any)).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
Cache: () => cache,
|
||||
|
||||
Reference in New Issue
Block a user